fix(acp): recover from persist() failure instead of cascading (#3366)#3383
Merged
Conversation
The writeChain pattern in FileAcpLocalStorageProfile.persist() chained .then() without error recovery. A single failed write (ENOENT, EACCES, inode change) poisoned all subsequent writes because every new .then() chained onto the rejected promise — blocking ALL session creation permanently. Fix: - persist() now catches write errors, logs them, cleans up stale tmp files, and resets the writeChain to Promise.resolve() - If the previous write failed, the current write still gets a fresh attempt via the .then(onFulfilled, onRejected) rejection handler - stop() swallows pending chain rejections so shutdown always completes - Added getPersistError() for diagnostics/health checks - Added 3 regression tests covering recovery, cascade prevention, and graceful shutdown
Contributor
There was a problem hiding this comment.
✅ Approved.
P1 fix — clean error recovery pattern for the persist() cascade bug.
- persist() catches errors, logs via structured logger, cleans up stale tmp file, resets writeChain so next write gets a fresh attempt.
- Both .then() handlers (success + recovery) execute the write — ensures no cascade.
- stop() swallows chain errors — clean shutdown guaranteed.
- getPersistError() on interface for diagnostics.
- 3 tests covering recovery, multiple sequential failures, and clean stop.
CI green. All merge gates pass. Merging.
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
Fixes #3366
FileAcpLocalStorageProfile.persist()chained writes ontowriteChainwithout error recovery. A single failed write (ENOENT, EACCES, inode change) permanently poisoned all subsequent writes because every.then()chained onto the rejected promise — blocking ALL session creation.Root Cause
Fix
Changes
persist(): error recovery with chain reset on failurestop(): catches pending chain rejections so shutdown always completesgetPersistError(): new method for diagnostics/health checksVerification
Verification