fix: clean up stale lock files during extension activation to prevent hangs on btrfs #10533
+315
−2
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.
Related GitHub Issue
Closes: #10436
Roo Code Task Context (Optional)
This PR was created by Roomote to address the reported issue.
Description
This PR attempts to address Issue #10436 where the extension hangs during activation on OSS Code (Arch Linux) with a btrfs filesystem.
Root Cause Analysis:
The
safeWriteJsonfunction usesproper-lockfilefor advisory locking during JSON file operations. On btrfs (and potentially other copy-on-write filesystems), the stale lock detection mechanism may not work correctly because:Solution:
Added a
cleanupStaleLocks()function that:.lockfiles/directories created byproper-lockfilesafeWriteJsonoperationsKey implementation details:
proper-lockfile(31 seconds) for consistencyTest Procedure
Unit tests added covering:
To manually test the fix:
Run the tests:
Pre-Submission Checklist
Screenshots / Videos
N/A - No UI changes.
Documentation Updates
Additional Notes
This is an attempt to address the issue based on the user's feedback that:
Feedback and guidance are welcome!
Get in Touch
Roomote Bot
Important
Introduces
cleanupStaleLocks()to remove stale lock files during extension activation, preventing hangs on btrfs filesystems.cleanupStaleLocks()insafeWriteJson.tsto remove stale lock files older than 31 seconds.activate()inextension.tsto prevent hangs on btrfs during extension activation.safeWriteJson.test.tsforcleanupStaleLocks()covering scenarios like empty directories, stale lock detection, recursive cleaning, and error handling.LOCK_STALE_MSconstant insafeWriteJson.ts.This description was created by
for 7511c6b. You can customize this summary. It will automatically update as commits are pushed.