openclaw - 💡(How to fix) Fix Session file lock not released on abnormal exit, blocking subsequent requests

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Workaround

Manually delete the .lock file:

rm /path/to/session.jsonl.lock

Code Example

Agent failed before reply: session file locked (timeout 60000ms): pid=XXXX /path/to/session.jsonl.lock

---

rm /path/to/session.jsonl.lock
RAW_BUFFERClick to expand / collapse

Bug Description

When an agent process terminates abnormally (e.g. crash, kill, network timeout), the session .lock file is not cleaned up. This causes subsequent requests to the same session to fail with:

Agent failed before reply: session file locked (timeout 60000ms): pid=XXXX /path/to/session.jsonl.lock

Steps to Reproduce

  1. Agent process holding a session lock dies unexpectedly
  2. Next message to the same session arrives
  3. Lock file still exists, new process cannot acquire lock within 60s timeout
  4. Request fails

Expected Behavior

  • Stale lock files should be detected and handled automatically (e.g. lock expires after N seconds, or detect that the holding PID no longer exists)
  • Alternatively, add a cleanup hook on process exit (SIGTERM/SIGINT) to release locks

Workaround

Manually delete the .lock file:

rm /path/to/session.jsonl.lock

Environment

  • OpenClaw: latest (npm global install)
  • OS: macOS 15.5 (arm64)
  • Node: v26.0.0

Suggested Fix

  1. PID-based stale detection: Before waiting for a lock, check if the PID in the lock file is still running. If not, treat the lock as stale and remove it.
  2. Lock timeout: Add a max age to lock files (e.g. 5 minutes). If a lock is older than the threshold, consider it stale.
  3. Process exit hooks: Register cleanup handlers for SIGTERM/SIGINT/SIGBREAK to release locks on graceful shutdown.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING