Skip to content

[Bug]: update.run (and gateway restart) should flush open session JSONL transcripts before SIGTERM #41538

@oliverchoy

Description

@oliverchoy

Bug type

Behavior bug (incorrect output/state without crash)

Summary

When update.run is triggered, the gateway sends SIGTERM and restarts immediately. Any active session's JSONL transcript that hasn't been fully flushed to disk is lost. The webchat UI caches the conversation client-side (so the user can still scroll up and read it), but the server-side transcript file is never written — making the session unrecoverable after page refresh.

Steps to reproduce

Have an active webchat session with a long conversation in progress
Trigger update.run (via gateway tool, CLI, or UI button)
Gateway restarts, webchat reconnects
Check ~/.openclaw/agents/main/sessions/ — the session from before the restart has no JSONL file

Expected behavior

Before executing SIGTERM, update.run (and gateway.restart) should:

Flush all open session JSONL file handles (fsync)
Then proceed with restart

Actual behavior

Session transcript is lost. No JSONL file written for the active session at time of restart.

OpenClaw version

2026.3.7

Operating system

macOS 26.3.1 (Sequoia), arm64 (Apple Silicon)

Install method

npm global

Logs, screenshots, and evidence

2026-03-09T04:45:01.819Z [gateway] update.run completed actor=openclaw-control-ui ... restartReason=update.run status=ok
2026-03-09T04:45:01.820Z [ws] ⇄ res ✓ update.run 26627ms conn=98b84633…3e44 id=f2ca0ab3…c887
2026-03-09T04:45:03.828Z [gateway] received SIGUSR1; restarting
2026-03-09T04:45:03.898Z [ws] webchat disconnected code=1012 reason=service restart conn=98b84633-9a4c-415c-8788-e806b55f3e44
2026-03-09T04:45:05.960Z [gateway] signal SIGTERM received


- conn=98b84633 was open since 2026-03-09T00:42 UTC (active for ~4 hours)
- update.run completed at 04:45:01
- SIGUSR1 → restart at 04:45:03 (2 seconds later)
- webchat disconnected at 04:45:03 — no flush step between restart and disconnect
- New gateway up at 04:45:06 — no session file exists for the prior conn

Impact and severity

  • Entire conversation history unrecoverable server-side after restart
  • Memory/context from that session is lost permanently
  • In my case: ~90 minutes of active debugging work lost

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions