fix(config): serialize async config writes to prevent data loss on startup#205
Open
BingqingLyu wants to merge 14 commits intomainfrom
Open
fix(config): serialize async config writes to prevent data loss on startup#205BingqingLyu wants to merge 14 commits intomainfrom
BingqingLyu wants to merge 14 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.