test: wait for rules-proxy watchers before changing _redirects - #8560
Merged
Merged
Conversation
createRewriter starts its chokidar watchers without waiting for them to be ready. The reload test rewrote _redirects right after the first request, and on slow macOS runners that write sometimes landed before the watcher was armed, so the change was never reported and the test timed out (2 of the last 10 macOS unit runs).
Contributor
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (1)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
paulo
enabled auto-merge (squash)
October 5, 2026 09:36
📊 Benchmark resultsComparing with 086fbfc
|
commit: |
chokidar types the 'ready' listener as () => void, so passing the Promise resolve function directly failed typecheck.
JakeChampion
approved these changes
Oct 5, 2026
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.
Summary
This fixes a flaky unit test from #8553.
tests/unit/utils/rules-proxy.test.ts→ "reloads rules when the _redirects file changes" fails intermittently on macOS:It failed in 2 of the last 10
Unit (macOS-latest, 24)runs (on #8558's branch at81a5cc3b3and57eb7cd32). Neither failure has anything to do with that branch's changes.Cause:
createRewriterstarts its chokidar watchers without waiting for them to be ready. The test makes one request and then rewrites_redirects. When the write lands before the watcher has armed its file watch, the change is never reported:waitFortimeout instead of the usual ~200ms for the whole file;On fast machines the first request (which builds the matcher) outlasts watcher setup, so the test usually passes.
Fix: the
rewriterFortest helper waits for every watcher'sreadyevent before returning.createRewriterreturns synchronously right after starting the watchers, andreadyonly fires after filesystem I/O, so the listener is always attached in time and can't hang. Production code is unchanged. A person editing_redirectsduringnetlify devdoes so long after the watchers are ready.How this was verified
generate-autocompletionfailure also happens onmain.