Skip to content

fix(watch): avoid restarting macOS watcher for unchanged paths - #10992

Merged
shulaoda merged 3 commits into
rolldown:mainfrom
sep2:fix/skip-empty-watch-path-batches
Sep 25, 2026
Merged

shulaoda merged 3 commits into
rolldown:mainfrom
sep2:fix/skip-empty-watch-path-batches

Conversation

@sep2

@sep2 sep2 commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Problem

FsWatcher::watch_paths() opens backend.paths_mut() before checking whether any paths need to be registered. Bundled dev calls this after each completed HMR build, and watch mode also updates its watch paths during builds, so an unchanged graph repeatedly opens and commits empty native watcher batches.

On macOS, the FSEvents backend in rolldown-notify stops its live stream when the batch is opened and starts another stream with kFSEventStreamEventIdSinceNow when it is committed. A file edit during that gap can be lost before Rolldown receives a watch event. The final edit can therefore leave output stale until another save, even though the watched paths never changed. Both immediate and debounced native watching are affected.

Change

  • Filter and deduplicate new paths before opening the native batch.
  • Return without touching the backend when no new paths remain.
  • Allocate owned paths only for new candidates, and continue recording them only after registration and commit succeed.
  • Document why an empty batch is not harmless on macOS.

This changes neither debounce settings nor the JavaScript API, and adds no polling or dependency changes.

Regression tests

  • Platform-independent tests reject any backend batch for empty input, already-watched paths, or a fully excluded batch.
  • macOS tests cover both immediate and debounced native watchers. They write to an existing watched file inside the exclusion predicate, placing the save deterministically in the old stopped-stream window, and require its event to arrive. They use no sleeps or probabilistic burst timing; the receive timeout is only a failure deadline.

All five new regression tests fail on the original implementation and pass with the fix.

Verification

  • cargo +1.98.1 test -p rolldown_fs_watcher -p rolldown_watcher -p rolldown_dev --lib — 29 tests passed.
  • cargo +1.98.1 clippy -p rolldown_fs_watcher --all-targets -- -D warnings — passed.
  • cargo +1.98.1 fmt --all --check — passed.
  • Repeated both macOS native regressions 20 times — all 40 checks passed.

@sep2
sep2 marked this pull request as ready for review September 24, 2026 20:20
@codspeed

codspeed Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing sep2:fix/skip-empty-watch-path-batches (3362ddd) with main (8df4219)2

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (5f873ad) during the generation of this report, so 8df4219 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@shulaoda shulaoda self-assigned this Sep 25, 2026
@sapphi-red

Copy link
Copy Markdown
Member

Why shouldn't this be fixed on the notify side?

@shulaoda shulaoda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@shulaoda
shulaoda merged commit aa1564b into rolldown:main Sep 25, 2026
32 checks passed
@shulaoda

shulaoda commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Why shouldn't this be fixed on the notify side?

Maybe we should consider it. 🤔

@sep2

sep2 commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

It probably should be fixed on the notify side too, but handling event continuity across real FSEvents restarts is more work than I want to take on right now. This Rolldown change is a small mitigation for unnecessary restarts, not a complete fix.

@rolldown-guard rolldown-guard Bot mentioned this pull request Sep 30, 2026
shulaoda added a commit that referenced this pull request Sep 30, 2026
## [1.2.12] - 2026-09-30

### 🚀 Features

- inline common chunks containing import() and deduplicate shared code in lazy chunks (#11034) by @hyfdev
- experimental `inlineCommonChunks` support (#10899) by @hyfdev
- dev: ship imported bindings for HMR partial accept (#10856) by @h-a-n-a

### 🐛 Bug Fixes

- chunking: re-derive chunk exec orders after the runtime leaves its host chunk (#11005) by @hyfdev
- code-splitting: gate member-read init paths on the reading statement (#11039) by @hyfdev
- code-splitting: retain initialization paths through re-exported namespaces (#11037) by @hyfdev
- dev: reject non-ESM output formats in dev mode (#11038) by @h-a-n-a
- dev: align `import.meta.hot.accept` deps with Vite (#10997) by @h-a-n-a
- dev: clear the resolver cache when a file is created or deleted (#10986) by @waltuov
- error: name the resolved specifier in unresolved import diagnostics (#11014) by @linyiru
- make entries-aware chunk merging deterministic (#11002) by @hyfdev
- watch: avoid restarting macOS watcher for unchanged paths (#10992) by @sep2

### 🚜 Refactor

- dev: ship the dev runtime entry as one file (#10998) by @h-a-n-a
- binding: remove `__internalForcePanic` (#10989) by @IWANABETHATGUY

### 📚 Documentation

- fix cloudflare preview builds (#10996) by @sapphi-red
- fix build config loader warning (#10994) by @sapphi-red
- deps: use Vite 8 (#10993) by @sapphi-red

### ⚡ Performance

- dev: only ship rows with dynamic edges in registerGraph (#11019) by @h-a-n-a

### 🧪 Testing

- code-splitting: cover more re-exported namespace shapes (#11042) by @hyfdev
- webcontainer: cover the WebContainer download fallback in plain Node (#10966) by @shulaoda
- dev: pin the runtime entry file layout that Vite serves (#10983) by @h-a-n-a

### ⚙️ Miscellaneous Tasks

- pin VOID_API_URL for the docs deploy (#11041) by @shulaoda
- opt into the WebContainer smoke test for napi bumps and loader changes (#10967) by @shulaoda
- deps: upgrade oxc to 0.152.0 (#11018) by @camc314
- deps: update rust crates (#11012) by @renovate[bot]
- deps: update npm packages (#11011) by @renovate[bot]
- deps: update crate-ci/typos action to v1.50.3 (#11023) by @renovate[bot]
- deps: update test262 submodule for tests (#11022) by @rolldown-guard[bot]
- deps: update rollup submodule for tests to v4.63.5 (#11021) by @rolldown-guard[bot]
- deps: update dependency vite-plus to v1 (#11017) by @renovate[bot]
- deps: update github actions (#11010) by @renovate[bot]
- remove `CLAUDE.md` (#10925) by @iiio2
- verify release debug info by matching file IDs (#10988) by @IWANABETHATGUY
- deps: update rollup submodule for tests to v4.63.4 (#10940) by @rolldown-guard[bot]

### ❤️ New Contributors

* @waltuov made their first contribution in [#10986](#10986)
* @linyiru made their first contribution in [#11014](#11014)
* @sep2 made their first contribution in [#10992](#10992)

Co-authored-by: shulaoda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants