-
-
Notifications
You must be signed in to change notification settings - Fork 736
fix(native-watcher): fix aggregate handler trigger #12203
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for rspack canceled.
|
📦 Binary Size-limit
❌ Size increased by 1.63KB from 47.45MB to 47.46MB (⬆️0.00%) |
CodSpeed Performance ReportMerging #12203 will not alter performanceComparing Summary
|
a660330 to
91c78a1
Compare
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 the aggregate handler trigger mechanism in the native watcher by introducing a last_changed field to track when the last file change occurred. The aggregate handler now monitors this timestamp and triggers only after the specified timeout has elapsed since the last change, rather than triggering immediately.
Key Changes
- Introduced
last_changed: Arc<RwLock<Option<Instant>>>to track the timestamp of the last file system event - Refactored aggregate task to use a polling loop that checks elapsed time since last change
- Restructured test helpers with new macros and improved error handling
- Added comprehensive tests for single and multiple file watching scenarios
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| crates/rspack_watcher/src/executor.rs | Core logic changes: added last_changed field and refactored aggregate timeout handling from event-based to time-based polling |
| crates/rspack_watcher/tests/watcher.rs | New test cases for single file, ignored files (glob/regex), and multiple file watching scenarios |
| crates/rspack_watcher/tests/helpers/mod.rs | Added collect_events (non-blocking), tick_ms, improved error handling, and changed time precision to microseconds |
| crates/rspack_watcher/tests/helpers/macros.rs | Extracted test macros into separate module for better organization |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Pass more native watcher tests.
last_changedto indicate when the last change was made. This field is monitored by the event aggregation handler. Once timeout, the handler will be triggered, otherwise the thread will be put to sleep for the remaining duration. (This fixed the case ofshould watch multiple fileswhere aggregation handler is not triggered according to the last modification)Related links
Checklist