fix(config): serialize async config writes to prevent data loss on startup#40464
fix(config): serialize async config writes to prevent data loss on startup#40464sahancava wants to merge 14 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR fixes a config data-loss bug (#40410) where What changed:
Concerns:
Confidence Score: 4/5
Last reviewed commit: f1063a7 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa9b3c5bbe
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b5df3f4811
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1368ae87d6
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
920eaf4 to
cc28c67
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cc28c670d5
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
The two failing CI checks appear unrelated to this PR. This PR only changes:
The failing checks are in other areas (including Windows/secrets-related tests), and I was able to reproduce them independently of this change. I kept this PR scoped to the config write bugfix only. |
|
I also updated/synced the branch, and these two failures still appear unrelated to the config write fix in this PR. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e0dc138c9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
ed62284 to
0a8155a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 333c48d6ac
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
f196dbf to
03f536e
Compare
9600691 to
f442717
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb38add833
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
6eb520d to
f2dad57
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f2dad578a3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
f2dad57 to
6c50fc4
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c50fc473b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
6c50fc4 to
a866885
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 568295217f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
5682952 to
4923f71
Compare
Summary
Describe the problem and fix in 2–5 bullets:
openclaw.json) can be wiped or truncated down to a minimal skeleton (~10 lines), resulting in data loss.configWriteQueueinsrc/config/io.tsto strictly serialize config disk writes.ownerDisplaySecretauto-persist routine to perform an atomic read-modify-write inside the queue lock, rather than computing a merge patch using a stale config snapshot..loadConfig()with.readConfigFileSnapshotForWrite()during secrets persistence to avoid permanently baking ephemeral runtime overrides.createConfigIO()andruntimeConfigSnapshotstate before entering the write queue to prevent execution-time path or environment shifts.throw Error) instead of silently returning on invalid snapshots.runtimeConfigSnapshot).OpenClawConfig, JSON patching mechanisms (merge patch), and general config parsing behavior remain untouched.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
Users will no longer lose their
~/.openclaw/openclaw.jsonconfiguration file when restarting the Gateway or restarting their system. No defaults or config schemas were changed.Security Impact (required)
Yes, explain risk + mitigation: N/ARepro + Verification
Environment
gateway.port,gateway.auth)Steps
~/.openclaw/openclaw.jsonfile.Expected
Actual
ownerDisplaySecretand basic defaults.Evidence
Attach at least one:
(Note: Added
src/config/io.write-config-queue.test.tsto reproduce the race condition exactly. The tests pass with this fix).Human Verification (required)
What you personally verified (not just CI), and how:
ownerDisplaySecretpattern with concurrentwriteConfigFilecalls to verify the stale snapshot issue is fully mitigated by the internal queue lock.Review Conversations
Compatibility / Migration
YesFailure Recovery (if this breaks)
openclaw.json.Risks and Mitigations
configWriteQueue) could theoretically deadlock if a config write throws a catastrophic unhandled error without resolving..finally()(via.then(success, failure)) to catch any thrown errors and properly advance the queue to the next write operation, ensuring no deadlocks ever occur.