fix(test): polling wait in server.test.ts fixes Node 22 flake#105
Merged
Conversation
The ``EmbeddedServer wraps logging callbacks with active-record fallback`` test fired once on PR #103's CI run and once on the post-merge ``main`` run with the same root cause: ``setTimeout(50)`` to drain a fire-and-forget ``logCallStart`` is not enough on Node 22 (~10 % failure rate) — the async scheduler defers the atomic-write resolve a tick longer than on Node 20 where the test was originally tuned. Replaced the fixed wait with a bounded poll: walk ``tmp`` for ``metadata.json`` every 25 ms up to 2 s, break on first hit. Same assertion, no behaviour change in the SUT, fast path is unchanged (the file lands within ~30 ms on both Node versions when the system is idle).
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
The
EmbeddedServer wraps logging callbacks with active-record fallbacktest inlibraries/typescript/tests/server.test.tsflakes on Node 22 (~10 % CI fail rate) because thesetTimeout(50)used to drain a fire-and-forgetlogCallStartpromise isn't enough — Node 22's async scheduler defers the atomic-write resolve a tick longer than Node 20 where the original 50 ms was tuned.Same failure showed up on PR #103 CI and again on the post-merge run.
Implementation
Replaced the fixed 50 ms wait with a bounded poll: walk
tmpformetadata.jsonevery 25 ms, break on first hit, hard ceiling 2 s. No behaviour change in the SUT.Breaking change?
No.
Test plan
cd libraries/typescript && npm run lintcleannpm test -- tests/server.test.ts— 37/37 pass locally