openclaw - 💡(How to fix) Fix Session file lock leak when user manually aborts agent (non-timeout abort never releases lock) [2 pull 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…

When a user manually stops an agent, the session file lock is never released, causing subsequent turn attempts to fail with SessionWriteLockTimeoutError for 60+ seconds.

Error Message

  • log.warn("failed to release session lock on abort: runId=" + params.runId + " " + String(err));

Root Cause

File: selection-C4e-Qn9W.js (bundled), function abortRun:

const abortRun = (isTimeout = false, reason) => {
    aborted = true;
    // ...
    abortCompaction();
    abortActiveSession();
    // BUG: releaseHeldLockForAbort() only called for timeout abort
    if (isTimeout) sessionLockController.releaseHeldLockForAbort().catch(...)
};

releaseHeldLockForAbort() is guarded by if (isTimeout). When user aborts manually, isTimeout=false, so the lock is never released.

Fix Action

Fixed

Code Example

const abortRun = (isTimeout = false, reason) => {
    aborted = true;
    // ...
    abortCompaction();
    abortActiveSession();
    // BUG: releaseHeldLockForAbort() only called for timeout abort
    if (isTimeout) sessionLockController.releaseHeldLockForAbort().catch(...)
};

---

- if (isTimeout) sessionLockController.releaseHeldLockForAbort().catch(...);
+ sessionLockController.releaseHeldLockForAbort().catch((err) => {
+     log.warn("failed to release session lock on abort: runId=" + params.runId + " " + String(err));
+ });
RAW_BUFFERClick to expand / collapse

Description

When a user manually stops an agent, the session file lock is never released, causing subsequent turn attempts to fail with SessionWriteLockTimeoutError for 60+ seconds.

Steps to Reproduce

  1. Start any agent conversation
  2. While agent is mid-response (e.g., waiting on LLM API), manually stop the agent
  3. Immediately try to send another message to the same agent

Expected Behavior

Agent should recover and accept new messages immediately after abort.

Actual Behavior

Root Cause

File: selection-C4e-Qn9W.js (bundled), function abortRun:

const abortRun = (isTimeout = false, reason) => {
    aborted = true;
    // ...
    abortCompaction();
    abortActiveSession();
    // BUG: releaseHeldLockForAbort() only called for timeout abort
    if (isTimeout) sessionLockController.releaseHeldLockForAbort().catch(...)
};

releaseHeldLockForAbort() is guarded by if (isTimeout). When user aborts manually, isTimeout=false, so the lock is never released.

Failure Chain

  1. User manual abort → abortRun(isTimeout=false)releaseHeldLockForAbort() SKIPPED → lock remains held
  2. Run cleanup → acquireForCleanup()acquireCleanupLock()takeHeldLockAfterRetainedIdle() fails (lock in use)
  3. Falls back to acquireLock() → lock already held → waits 60s → SessionWriteLockTimeoutError
  4. cleanupEmbeddedAttemptResources() never reached → lock NEVER released
  5. Only freed by watchdog (maxHoldMs, default 300s) or gateway restart

Relevant Logs

Suggested Fix

- if (isTimeout) sessionLockController.releaseHeldLockForAbort().catch(...);
+ sessionLockController.releaseHeldLockForAbort().catch((err) => {
+     log.warn("failed to release session lock on abort: runId=" + params.runId + " " + String(err));
+ });

Environment

  • OpenClaw version: 2026.5.27
  • Node: v22.22.1
  • OS: Linux (Ubuntu 7.0.0-15-generic)
  • Provider: DeepSeek (deepseek-v4-pro)

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

openclaw - 💡(How to fix) Fix Session file lock leak when user manually aborts agent (non-timeout abort never releases lock) [2 pull requests]