Repository navigation
fix(lsp): rescan when a watched directory is replaced while its watch attaches - #268
Merged
Merged
Conversation
… attaches The tsserver hook worker learned of a replaced ancestor directory only from the parent watcher's event. On macOS a directory fs.watch is an FSEvents stream that starts asynchronously, so a replacement made while the watch attaches can send no event; on a loaded runner //tests/lsp:test_worker_map then waited out its 60 s timeout. After attaching a watch, the worker now re-stats the directory and schedules a rebuild when its identity changed. rebuildTimer moves above the initial build, which can now schedule a rebuild during its own watch attachment. The test drops the parent's event for the replaced directory, as FSEvents can, so it fails without the re-check on every platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On macOS the tsserver hook worker can miss a directory replaced while its watch attaches, so an editor keeps a stale resolution map and
//tests/lsp:test_worker_maphangs until its 60 s timeout, failing macOS CI.Problem
The worker learns that a watched ancestor was replaced only from the parent watcher's event. On macOS a directory
fs.watchis an FSEvents stream that starts asynchronously, and a change made while it starts sends no event. Under load, that window covers the test's replacement, so the worker never rebuilds. Linux inotify is live whenfs.watchreturns, which is why Linux passes.Observed in production
Not observed in production; the worker is editor tooling. It failed rules_typescript#267's macOS unit job twice, on a runner busy compiling oj from scratch. An editor on a loaded Mac can hit the same gap.
Gain
The worker no longer depends on an event FSEvents may drop, so replacements reach the map on every platform, and #267's macOS job stops timing out.
What changes
rebuildTimeris declared before the initial build, which can now schedule a rebuild during its own watch attachment. Previously that call hit the uninitializedletand was swallowed bywatchDirectory's error handler.worker_map_test.mjsdrops the parent's event for the replaced directory, as FSEvents can, so the test fails without the re-check on Linux too.🤖 Generated with Claude Code