-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
[Bug]: Config file concurrent write race truncates openclaw.json to 61 bytes #89331
Copy link
Copy link
Closed
Closed
Copy link
Labels
P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.ClawSweeper needs more reporter information before it can verify this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.Thin issue quality; more reproduction proof or environment detail is needed.
Metadata
Metadata
Assignees
Labels
P0Emergency: data loss, security bypass, crash loop, or unusable core runtime.Emergency: data loss, security bypass, crash loop, or unusable core runtime.clawsweeper:needs-infoClawSweeper needs more reporter information before it can verify this issue.ClawSweeper needs more reporter information before it can verify this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:crash-loopCrash, hang, restart loop, or process-level availability failure.Crash, hang, restart loop, or process-level availability failure.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.issue-rating: 🦪 silver shellfishThin issue quality; more reproduction proof or environment detail is needed.Thin issue quality; more reproduction proof or environment detail is needed.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Bug: Config file concurrent write race truncates openclaw.json
What happened
When the Gateway daemon and a CLI tool (or two Gateway processes) write ~/.openclaw/openclaw.json concurrently, the file can be truncated to ~61 bytes, corrupting the entire configuration and causing service interruption.
Environment
Reproduction
This has been observed at least twice in production use.
Root cause analysis
The config write uses an atomic-write pattern (write temp, fsync, rename), but there is no file-level locking to prevent two writers from racing. When both writers read the file at nearly the same time, one write overwrites the other's changes. In worst case, the temp file rename races with a read, producing a truncated file.
The missing-meta-before-write log entries on every config read suggest the meta field is stripped during reads, compounding the data loss.
Suggested fix
Add a proper file lock (e.g., proper-lockfile npm package) around all config read-modify-write operations in both the Gateway daemon and CLI tools. The lock should be:
Impact