-
-
Notifications
You must be signed in to change notification settings - Fork 955
fix(cli): avoid clearing cache early to prevent race condition in watch mode #5054
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
Conversation
✅ Deploy Preview for unocss ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Pull request overview
This PR fixes a race condition in watch mode by deferring cache clearing until after new data is populated. Previously, clearing the cache at the start of parseEntries could cause concurrent reads during async file operations to see an empty cache.
Key changes:
- Changed cache update strategy from clear-then-populate to build-new-then-swap
- Cache now remains valid throughout the async file reading operations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cache.clear() | ||
| for (const [key, value] of newCache) | ||
| cache.set(key, value) |
Copilot
AI
Jan 9, 2026
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.
Consider adding a test that verifies the race condition fix by simulating concurrent access to the cache during watch mode updates. The test should ensure that the cache remains accessible with valid data while parseEntries is executing, particularly during the file reading operations between lines 99-105.
|
commit: |
fixed #5038