-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: eliminate getStorageBasePath race condition and vscode popup #7174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: eliminate getStorageBasePath race condition and vscode popup #7174
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! This PR effectively addresses the race condition issue in getStorageBasePath(). The fix is clean, minimal, and well-tested. I've left a few minor suggestions for potential improvements, but the current implementation looks solid and ready to merge.
|
|
||
| // Test if path is writable | ||
| const testFile = path.join(customStoragePath, ".write_test") | ||
| // Test if path is writable (use unique filename to avoid race conditions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great fix! Consider making the comment slightly more detailed to explain why we need the unique suffix, e.g.:
| // Test if path is writable | ||
| const testFile = path.join(customStoragePath, ".write_test") | ||
| // Test if path is writable (use unique filename to avoid race conditions) | ||
| const uniqueSuffix = `${Date.now()}-${Math.random().toString(36).slice(2, 11)}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unique suffix generation pattern works well. As a minor enhancement for future consideration, this could be extracted to a small utility function if similar unique ID generation is needed elsewhere in the codebase. But for a single use case, the current implementation is perfectly fine.
| vi.restoreAllMocks() | ||
| }) | ||
|
|
||
| it("should handle concurrent storage validations without race conditions", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent test coverage for the race condition scenario! For future enhancements, consider adding test cases for:
- Custom path becoming inaccessible during runtime
- Invalid/non-writable custom path handling
- Fallback to default path when custom path fails
These would provide even more comprehensive coverage of edge cases.
|
Closing in favor of #7164 |
Related GitHub Issue
Closes: # 7173
Roo Code Task Context (Optional)
N/A
Description
When using vscode setting
roo-cline.customStoragePaththere is a race condition in getStorageBasePath().Update getStorageBasePath() to append a random suffix to
.write_testfile to prevent a race condition where concurrent operations want to read or remove the file.add a test to verify functionality.
Test Procedure
Pre-Submission Checklist
Screenshots / Videos
n/a
Documentation Updates
Does this PR necessitate updates to user-facing documentation?
Additional Notes
n/a
Get in Touch
jim.weller
Important
Fix race condition in
getStorageBasePathby appending unique suffix to test file, ensuring concurrent operations do not conflict.getStorageBasePathinstorage.tsby appending unique suffix to.write_testfile.storage.test.tsto verify concurrent storage validations handle race conditions correctly.This description was created by
for 6f3f6eb. You can customize this summary. It will automatically update as commits are pushed.