Revert "fix: use safeWriteJson for all JSON file writes"#4471
Merged
Conversation
This reverts commit 1be30fc.
jr
approved these changes
Jun 9, 2025
cte
approved these changes
Jun 9, 2025
daniel-lxs
approved these changes
Jun 9, 2025
Contributor
|
See also: #4468 |
daniel-lxs
pushed a commit
that referenced
this pull request
Jun 21, 2025
Fix race condition where safeWriteJson would fail with ENOENT errors
during lock acquisition when the parent directory was just created.
The issue occurred when the directory creation hadn't fully synchronized
with the filesystem before attempting to acquire a lock. This happened
primarily when Task.saveApiConversationHistory() called the function
immediately after creating the task directory.
The fix ensures directories exist and are fully synchronized before
lock acquisition by:
- Creating directories with fs.mkdir({ recursive: true })
- Verifying access to created directories
- Setting realpath: false in lock options to allow locking non-existent files
Added comprehensive tests for directory creation capabilities.
Fixes: #4468
See-also: #4471, #3772, #722
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
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.
Reverts #3772
Looks like this causes issues with saving history, and possibly other things.
Important
Reverts atomic JSON file writes using
safeWriteJson, replacing withfs.writeFile, and updates related tests and documentation.safeWriteJsonfor JSON file writes, replacing it withfs.writeFileinmodelCache.ts,modelEndpointCache.ts,importExport.ts,FileContextTracker.ts,apiMessages.ts,taskMessages.ts,webviewMessageHandler.ts, andMcpHub.ts.safeWriteJson.safeWriteJsontests fromsafeWriteJson.test.ts.cache-manager.test.tsandMcpHub.test.tsto reflect changes fromsafeWriteJsontofs.writeFile.use-safeWriteJson.mdrule documentation.proper-lockfileandstream-jsonfrompackage.jsondependencies.This description was created by
for d47929e. You can customize this summary. It will automatically update as commits are pushed.