Skip to content

test: fix timing and environment flakes - #66320

Open
panva wants to merge 9 commits into
nodejs:mainfrom
panva:various-flakes-fixes
Open

panva wants to merge 9 commits into
nodejs:mainfrom
panva:various-flakes-fixes

Conversation

@panva

@panva panva commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Address races and environment dependencies in inspector/debugger, HTTP, ESM loader, watch, cluster, and styleText tests. The individual commits describe the failure mechanisms, fixes, and related issues.

Remove the corresponding flaky expectations, along with the stale HTTP request-timeout keepalive and watch argv entries whose fixes have already landed.

Verified with repeated local runs on macOS arm64 and Windows x64, including targeted reproductions of the socket binding, watch restart, and terminal environment failures.

A Windows socket bound to 127.0.0.1 can accept connections intended for
another process's wildcard listener on the same port. A competing
inspector can then answer the HTTP request with 400 or send plaintext
to the HTTPS client.

Bind both fixture servers to the address used by their requests to
prevent the competing bind. Bypass environment proxies so local HTTP
and HTTPS requests reach the fixture servers directly, and remove the
Windows flaky expectation.

Fixes: nodejs#59090
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Claude, Codex
Wait for the target to finish starting before attaching the debugger.
Capture the CLI close event when it is spawned so quit() also completes
after an early exit, and terminate the target before awaiting cleanup.
Add a regression test for quitting an already exited CLI and remove the
Windows flaky entry.

Refs: nodejs#63212
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
Wait for NodeRuntime.waitingForDebugger before sending the resume
command. Runtime.executionContextCreated does not guarantee that the
child has started waiting for the debugger.

Refs: https://github.com/nodejs/node/actions/runs/36224832165/job/108356717128
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
Await client end events before checking completed responses instead of
asserting completion at fixed deadlines. Keep the pending-request checks
and verify that the headers-only request expires before the later
successful request completes.

Refs: nodejs#54817
Refs: nodejs#43465
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Claude, Codex
The second request in the headers-timeout test could finish its headers
before the next periodic timeout check ran. Leave it incomplete across
multiple checking intervals before sending the remaining headers.

Remove both macOS keepalive flaky expectations. c3aa86d already
extended the request-timeout test's margin to allow multiple checks.

Refs: nodejs#42741
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Claude, Codex
Keep idle server connections open until the client closes them. This
avoids reusing a keep-alive socket the server closed while the loader
thread was stalled.

Refs: nodejs#47836
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Claude, Codex
Windows directory watchers report last-access time updates. Reading cold
fixtures in the child can therefore trigger test:watch:restarted before
it exits, failing the mustNotCall assertion without printing the error.

Read the fixtures before starting watch mode and remove the Windows
flaky expectation. With old access times and a delayed child exit, the
original fails 10/10 runs and the change passes 100/100 on Windows.

Also remove the argv variant's stale flaky expectation. It passes
repeated local Windows runs and the inspected CI history after nodejs#66035.

Refs: nodejs#66056
Refs: nodejs#66035
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Codex
common.isAlive() sends SIGCONT while polling exiting workers. On Linux,
this can discard a pending SIGSTOP from LeakSanitizer's ptrace attach,
leaving its thread-suspension loop waiting indefinitely.

Use signal 0 to check existence without changing the process state.
This also makes the liveness check work on Windows, where SIGCONT is
unsupported. Treat only ESRCH as a dead process and propagate other
errors. Remove the ASan flaky expectation.

Refs: nodejs#39655
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Claude, Codex
The TTY cases inherit TERM, CI and the color override variables. These
can disable colors in a case expecting styling, or force colors in a
case expecting plain text. The tests skip these cases without a TTY,
which hides the dependency in many standalone runs.

Set a color-capable TERM and only the environment variables specified
by each case. Remove the RISC-V flaky expectations.

Refs: nodejs/build#4099 (comment)
Signed-off-by: Filip Skokan <panva.ip@gmail.com>
Assisted-by: Claude, Codex
@panva panva added the commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. label Sep 26, 2026
@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure. labels Sep 26, 2026
@panva panva added the flaky-test Issues and PRs involving tests that fail intermittently in CI. label Sep 26, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.36%. Comparing base (66f26d3) to head (11d7658).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66320      +/-   ##
==========================================
- Coverage   90.38%   90.36%   -0.02%     
==========================================
  Files         790      790              
  Lines      274497   274514      +17     
  Branches    52557    52568      +11     
==========================================
- Hits       248100   248072      -28     
- Misses      16879    16932      +53     
+ Partials     9518     9510       -8     

see 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. esm Issues and PRs related to the ECMAScript Modules implementation. flaky-test Issues and PRs involving tests that fail intermittently in CI. needs-ci PRs that need a full CI run. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants