Repository navigation
test(server): wait for the activity holds state, not for one file event, in the link WebSocket fingerprints test - #8675
Conversation
…nt, in the link WebSocket fingerprints test
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
✅ Deterministic PR hygiene checks passed. |
|
macOS result for this head, measured by the coordinator (Bun 1.4.4, the merge tree of 0d1c6bd with dev, tree 3e587d35ca): 30 fresh-copy runs of the nine Fresh final review of this head: APPROVE WITH NITS, no P0-P2. One P3 is taken into a follow-up: a wrong mark count now fails as a 5000 ms timeout at the wait instead of "expected 1, received 2"; waiting for the state to change and keeping the exact check restores the message. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…-gate-evidence The layout maps (layout.json, layout-clients.json, test-layout-expected.json) are the union of both sides, checked key by key. structure/remote-link.md keeps both sides: this branch's paragraph is dev's plus the U11, real-Child, restart and Autobahn sentences. The gate file keeps this branch's version, in which #8668's labels and binary copy live in tests/helpers/link-gate-codex.ts.
Summary
tests/server/link-websocket-fingerprints.test.ts, in "through a real Home: a cut WebSocket turn and its HTTP resend", waited for the Home'slink/activity-holds.jsonwrite with a helper that armedfs.watchon the link directory just before the action that writes the file, and resolved on the first event naming the file. On macOS (Bun 1.4.4) a watcher is armed asynchronously, so the write can come before the watcher sees anything: the test then timed out at 5 s atawait held, the line afterws.destroy(), and teardown produced an unhandled ENOENT from a late read. An instrumented copy showed the file already held exactly the expected mark at the timeout: the Home had written the hold, and only the event was missed.Measured on macOS (30 fresh-copy runs of the link WebSocket server test files together, each tree): 2 failures in 30 on the tree with #8647, and 2 in 30 on dev before #8647 (3762722), every failure in this case. The race has been in the test since #8593 at the same rate, and #8647 did not change it. It has not been seen on Linux CI. The macOS shards run in the lane=all release-evidence batch, so it can turn a release run red.
The fix changes only the test. One watcher on the link directory is armed right after the test writes
links.json, before the Home starts, so it is armed several network round trips before the first holds write it has to see. Each wait is for a state, never for one event:until(condition)checks the condition (the fingerprinted mark count read from the holds file, treating a not-yet-written file as "not yet") when the wait starts and again on every event, so a write that lands before the wait begins is still seen. The second wait (after an HTTP resend answered 200, for the count to reach 0) uses the same helper; a resend refused with 400 leaves the mark and needs no wait. The watcher is closed before teardown removes the directory, so no event reads a removed file. No sleeps, polling loops or timers.No product seam was reachable from this test: the Home is started with
startServer(0), whose deps do not reach the link listener (the holds book'swriteHooksand the lifecycle'sactivityHoldsSettled()are not exposed through it), and adding one would change the product. The other link WebSocket test files have nofs.watchwaits.tests/server/link-websocket-upgrade.test.tswaits for holds with a short polling loop (waitForHolds), which cannot miss an event; it is left as it is.Verification
Only macOS shows the failure, and I could not run macOS: the failure could not be reproduced here first, and the fix is verified on Linux only.
bun run typecheck: exit 0bun run privacy:scan: exit 0bun scripts/test.ts --parallel=2over everylink-websocket-*.test.tsfile (tests/server: drain, fingerprints, gate, holds, pump, traffic, transport-status, upgrade; tests/e2e-style: release-gate, rss) andtests/responses/responses-websocket-workflow-ceiling.test.ts: exit 0 (156 pass, 9 skip, the release-gate cases that need the pinned codex-rs binary, 0 fail)bun test tests/server/link-websocket-fingerprints.test.ts, 8 runs in a row: 29 pass, 0 fail eachNOT RUN: macOS (where the race occurs); the full
bun run testsuite.Checklist