openclaw - 💡(How to fix) Fix session .jsonl.lock not cleaned up after session.ended, causes 60s timeout for subsequent requests

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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

Fix / Workaround

临时 workaround

Code Example

session file locked (timeout 60000ms): pid=13681 /Users/song/.openclaw/agents/xiaocai/sessions/eb0efa8f-6df7-43cc-a74f-93ebb1863503.jsonl.lock

---

-rw-------@ 1 song  staff  85 May 25 20:07 4795a72c-0ab8-4828-a724-2e8ec38e70ac.jsonl.lock

---

-rw-------@ 1 song  staff  85 May 25 22:43 eb0efa8f-6df7-43cc-a74f-93ebb1863503.jsonl.lock

---

{
  "pid": 13681,
  "createdAt": "2026-05-25T14:43:12.576Z",
  "maxHoldMs": 720000
}

---

#!/bin/bash
for lock_file in /Users/song/.openclaw/agents/xiaocai/sessions/*.jsonl.lock; do
    [ -f "$lock_file" ] || continue
    base="${lock_file%.lock}"
    trajectory="${base%.jsonl}.trajectory.jsonl"
    if [ -f "$trajectory" ] && grep -q '"session.ended"' "$trajectory"; then
        rm -f "$lock_file"
    fi
done
RAW_BUFFERClick to expand / collapse

Bug: session .jsonl.lock 文件在 session 结束后未被清理,导致后续请求超时 60000ms

问题描述

当 Agent session 正常结束(trajectory 中有 session.ended 事件)后,其对应的 .jsonl.lock 文件没有被 gateway 进程自动删除。这导致后续对该 session 的请求因等待锁超时而失败,错误信息:

session file locked (timeout 60000ms): pid=13681 /Users/song/.openclaw/agents/xiaocai/sessions/eb0efa8f-6df7-43cc-a74f-93ebb1863503.jsonl.lock

虽然锁有 maxHoldMs: 720000(12分钟)过期时间,但这意味着用户需要等待最多 12 分钟才能恢复,严重影响使用体验。

复现步骤

  1. 配置一个 agent(如 xiaocai),绑定飞书群聊
  2. 在群聊中触发 agent 执行长时间任务(如 adb 数据采集)
  3. 任务正常完成(trajectory 有 session.ended
  4. 再次向该 agent 发送消息
  5. 收到 session file locked (timeout 60000ms) 错误

环境

  • OpenClaw 版本: 2026.5.22 (a374c3a)
  • OS: macOS 15.5 (Darwin 25.5.0, arm64)
  • Node: v25.8.1
  • Model: bailian/qwen3.6-plus

证据

残留锁文件示例 1:

-rw-------@ 1 song  staff  85 May 25 20:07 4795a72c-0ab8-4828-a724-2e8ec38e70ac.jsonl.lock
  • 锁创建时间:2026-05-25T12:07:17Z(北京时间 20:07)
  • session.ended 时间:2026-05-25T12:08:17Z(北京时间 20:08)
  • 结论:session 结束后锁未被清理

残留锁文件示例 2:

-rw-------@ 1 song  staff  85 May 25 22:43 eb0efa8f-6df7-43cc-a74f-93ebb1863503.jsonl.lock
  • 锁创建时间:2026-05-25T14:43:12Z(北京时间 22:43)
  • session.ended 时间:2026-05-25T14:43:10Z(北京时间 22:43)
  • 结论:session 结束后锁未被清理

锁文件内容:

{
  "pid": 13681,
  "createdAt": "2026-05-25T14:43:12.576Z",
  "maxHoldMs": 720000
}

影响

  1. Agent session 结束后,用户发送消息会收到 60 秒超时错误
  2. 需要等待 12 分钟(maxHoldMs)锁自动过期才能恢复
  3. 同一问题在同一天内复现了 2 次(不同 session ID)

期望行为

session 正常结束后(session.ended 事件写入后),对应的 .jsonl.lock 文件应该被立即删除,而不是依赖 maxHoldMs 超时。

临时 workaround

写了一个清理脚本检测已结束的 session 并删除残留锁文件:

#!/bin/bash
for lock_file in /Users/song/.openclaw/agents/xiaocai/sessions/*.jsonl.lock; do
    [ -f "$lock_file" ] || continue
    base="${lock_file%.lock}"
    trajectory="${base%.jsonl}.trajectory.jsonl"
    if [ -f "$trajectory" ] && grep -q '"session.ended"' "$trajectory"; then
        rm -f "$lock_file"
    fi
done

但根本修复应该在 gateway 的 session 清理逻辑中处理。

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