Skip to content

fix(test): polling wait in server.test.ts fixes Node 22 flake#105

Merged
nicolotognoni merged 1 commit into
mainfrom
fix/0.6.2-flake-server-test-node22
May 25, 2026
Merged

fix(test): polling wait in server.test.ts fixes Node 22 flake#105
nicolotognoni merged 1 commit into
mainfrom
fix/0.6.2-flake-server-test-node22

Conversation

@nicolotognoni
Copy link
Copy Markdown
Collaborator

Summary

The EmbeddedServer wraps logging callbacks with active-record fallback test in libraries/typescript/tests/server.test.ts flakes on Node 22 (~10 % CI fail rate) because the setTimeout(50) used to drain a fire-and-forget logCallStart promise 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 tmp for metadata.json every 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 lint clean
  • npm test -- tests/server.test.ts — 37/37 pass locally
  • CI confirms Node 22 pass on this PR

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).
@nicolotognoni nicolotognoni merged commit 32c2f32 into main May 25, 2026
10 checks passed
@github-actions github-actions Bot deleted the fix/0.6.2-flake-server-test-node22 branch May 26, 2026 07:51
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.

1 participant