Repository navigation
test_runner: improve --test-timeout to be per test - #57672
Merged
nodejs-github-bot merged 10 commits intoApr 9, 2025
Merged
Conversation
Collaborator
|
Review requested:
|
jakecastelli
force-pushed
the
test-timeout-improvement
branch
from
March 29, 2025 11:34
fba5496 to
a982c95
Compare
aduh95
reviewed
Mar 29, 2025
aduh95
reviewed
Mar 29, 2025
jakecastelli
force-pushed
the
test-timeout-improvement
branch
from
March 29, 2025 11:41
b79d0c3 to
496c282
Compare
Previously `--test-timeout` is set on per test execution, this is obviously a bug as per test execution is hard to be expected, this patch addresses the issue by setting `timeout` from per execution to per test. This patch also fixes a minor issue that `--test-timeout` is not being respected when running without `--test`.
jakecastelli
force-pushed
the
test-timeout-improvement
branch
from
March 29, 2025 11:51
496c282 to
c1c48ec
Compare
aduh95
reviewed
Mar 29, 2025
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #57672 +/- ##
========================================
Coverage 90.22% 90.23%
========================================
Files 630 630
Lines 185055 185296 +241
Branches 36216 36342 +126
========================================
+ Hits 166975 167204 +229
+ Misses 11042 11011 -31
- Partials 7038 7081 +43
🚀 New features to boost your workflow:
|
pmarchini
reviewed
Mar 29, 2025
pmarchini
reviewed
Mar 30, 2025
pmarchini
approved these changes
Mar 30, 2025
cjihrig
reviewed
Mar 30, 2025
cjihrig
left a comment
Contributor
There was a problem hiding this comment.
A few nits, but this is looking a lot better than the current implementation. Thanks!
jakecastelli
force-pushed
the
test-timeout-improvement
branch
from
April 4, 2025 15:55
250ef6d to
8a713ec
Compare
jakecastelli
force-pushed
the
test-timeout-improvement
branch
from
April 4, 2025 15:56
8a713ec to
af2201e
Compare
jakecastelli
commented
Apr 4, 2025
jakecastelli
commented
Apr 4, 2025
jakecastelli
force-pushed
the
test-timeout-improvement
branch
from
April 4, 2025 16:27
1f2245c to
f593a7b
Compare
…Suite, unref timeout
jakecastelli
force-pushed
the
test-timeout-improvement
branch
from
April 4, 2025 16:35
f593a7b to
6559293
Compare
MoLow
approved these changes
Apr 7, 2025
pmarchini
approved these changes
Apr 9, 2025
Collaborator
|
Landed in 67786c1 |
|
Thank you! |
RafaelGSS
pushed a commit
that referenced
this pull request
May 1, 2025
Previously `--test-timeout` is set on per test execution, this is obviously a bug as per test execution is hard to be expected, this patch addresses the issue by setting `timeout` from per execution to per test. This patch also fixes a minor issue that `--test-timeout` is not being respected when running without `--test`. PR-URL: #57672 Fixes: #57656 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
RafaelGSS
pushed a commit
that referenced
this pull request
May 2, 2025
Previously `--test-timeout` is set on per test execution, this is obviously a bug as per test execution is hard to be expected, this patch addresses the issue by setting `timeout` from per execution to per test. This patch also fixes a minor issue that `--test-timeout` is not being respected when running without `--test`. PR-URL: #57672 Fixes: #57656 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Member
|
This seemed to cause test failures when cherry-picked to v22.x-staging. It's possible that the tests are relying on test runner features that cannot or have yet to be backported to v22.x-staging. |
8 tasks done
jeffyaw
added a commit
to YawLabs/aws-mcp
that referenced
this pull request
Aug 23, 2026
…child
Two fixes for the same failure mode -- an unbounded wait turning a failure
into a hang. `npm test` runs unattended inside release.sh, so a hang wedges
the release rather than aborting it.
1. The concrete defect. The credential-race test forks children and waits on
`child.once("message")` for a "ready" signal, with nothing on the failure
path. A child that dies BEFORE signalling -- an import throw, a stale
build -- never sends it, so the promise stays pending forever and the whole
suite hangs. It now also settles on `exit`, reporting the child's own exit
code. A late exit after res() is a no-op on an already-settled promise,
which is the normal path here: these children are expected to exit once
the race has been signalled.
2. The backstop. node:test has no default per-test timeout, so any future
unbounded wait has the same effect. --test-timeout=300000 is deliberately
generous -- measured files run ~7.5s worst case, so 5 minutes is ~40x
headroom and cannot false-fail, while still converting a hang into a
reported failure.
Note the semantics: until Node 24 the flag is per-FILE, not per-test
(nodejs/node#57672), so the value must clear the slowest FILE. Requires
Node >= 20.11.0 (nodejs/node#50443); dev-side script only, so engines is
left alone.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jeffyaw
added a commit
to YawLabs/electron-mcp
that referenced
this pull request
Aug 23, 2026
… a release node:test has NO default per-test timeout, so a test awaiting an event that never arrives runs forever. `npm test` runs unattended inside release.sh, so that turns a wedged release rather than a failed one -- the release just never returns. --test-timeout=300000 is a backstop, deliberately generous: measured test files run ~7.5s worst case here, so 5 minutes is roughly 40x headroom and cannot false-fail, while still converting an infinite hang into a reported failure. Note the semantics: until Node 24 the flag is per-FILE, not per-test (nodejs/node#57672), so the value has to clear the slowest FILE. Verified empirically rather than assumed -- and note that Node already catches the easy case (a pending promise with a drained event loop) on its own; the case this flag actually covers is a hang holding a live handle, e.g. a child process that never messages back. Requires Node >= 20.11.0 (nodejs/node#50443). This affects the dev-side test script only, not package consumers, so engines is left alone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jeffyaw
added a commit
to YawLabs/lemonsqueezy-mcp
that referenced
this pull request
Aug 23, 2026
… a release node:test has NO default per-test timeout, so a test awaiting an event that never arrives runs forever. `npm test` runs unattended inside release.sh, so that turns a wedged release rather than a failed one -- the release just never returns. --test-timeout=300000 is a backstop, deliberately generous: measured test files run ~7.5s worst case here, so 5 minutes is roughly 40x headroom and cannot false-fail, while still converting an infinite hang into a reported failure. Note the semantics: until Node 24 the flag is per-FILE, not per-test (nodejs/node#57672), so the value has to clear the slowest FILE. Verified empirically rather than assumed -- and note that Node already catches the easy case (a pending promise with a drained event loop) on its own; the case this flag actually covers is a hang holding a live handle, e.g. a child process that never messages back. Requires Node >= 20.11.0 (nodejs/node#50443). This affects the dev-side test script only, not package consumers, so engines is left alone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jeffyaw
added a commit
to YawLabs/lemonsqueezy-webhook-sink
that referenced
this pull request
Aug 23, 2026
… a release node:test has NO default per-test timeout, so a test awaiting an event that never arrives runs forever. `npm test` runs unattended inside release.sh, so that turns a wedged release rather than a failed one -- the release just never returns. --test-timeout=300000 is a backstop, deliberately generous: measured test files run ~7.5s worst case here, so 5 minutes is roughly 40x headroom and cannot false-fail, while still converting an infinite hang into a reported failure. Note the semantics: until Node 24 the flag is per-FILE, not per-test (nodejs/node#57672), so the value has to clear the slowest FILE. Verified empirically rather than assumed -- and note that Node already catches the easy case (a pending promise with a drained event loop) on its own; the case this flag actually covers is a hang holding a live handle, e.g. a child process that never messages back. Requires Node >= 20.11.0 (nodejs/node#50443). This affects the dev-side test script only, not package consumers, so engines is left alone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jeffyaw
added a commit
to YawLabs/npmjs-mcp
that referenced
this pull request
Aug 23, 2026
… a release node:test has NO default per-test timeout, so a test awaiting an event that never arrives runs forever. `npm test` runs unattended inside release.sh, so that turns a wedged release rather than a failed one -- the release just never returns. --test-timeout=300000 is a backstop, deliberately generous: measured test files run ~7.5s worst case here, so 5 minutes is roughly 40x headroom and cannot false-fail, while still converting an infinite hang into a reported failure. Note the semantics: until Node 24 the flag is per-FILE, not per-test (nodejs/node#57672), so the value has to clear the slowest FILE. Verified empirically rather than assumed -- and note that Node already catches the easy case (a pending promise with a drained event loop) on its own; the case this flag actually covers is a hang holding a live handle, e.g. a child process that never messages back. Requires Node >= 20.11.0 (nodejs/node#50443). This affects the dev-side test script only, not package consumers, so engines is left alone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
jeffyaw
added a commit
to YawLabs/tailscale-mcp
that referenced
this pull request
Aug 23, 2026
… a release node:test has NO default per-test timeout, so a test awaiting an event that never arrives runs forever. `npm test` runs unattended inside release.sh, so that turns a wedged release rather than a failed one -- the release just never returns. --test-timeout=300000 is a backstop, deliberately generous: measured test files run ~7.5s worst case here, so 5 minutes is roughly 40x headroom and cannot false-fail, while still converting an infinite hang into a reported failure. Note the semantics: until Node 24 the flag is per-FILE, not per-test (nodejs/node#57672), so the value has to clear the slowest FILE. Verified empirically rather than assumed -- and note that Node already catches the easy case (a pending promise with a drained event loop) on its own; the case this flag actually covers is a hang holding a live handle, e.g. a child process that never messages back. Requires Node >= 20.11.0 (nodejs/node#50443). This affects the dev-side test script only, not package consumers, so engines is left alone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Oct 4, 2026
aelmanaa
added a commit
to aelmanaa/hardhat-kms
that referenced
this pull request
Oct 6, 2026
`tasks-cli.test.ts` starts the Hardhat CLI 37 times across its 33 tests. No workflow runs the live scripts; they run locally. The file budgets go when the Node floor moves to a release that has nodejs/node#57672, not when any Node 22 release gets it. Two fixture comments and two test names say what they check. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
aelmanaa
added a commit
to aelmanaa/hardhat-kms
that referenced
this pull request
Oct 6, 2026
Closes #267 ## What changes On Node 22, `--test-timeout` limits each test file and sets no limit per test. On Node 24 and later it limits each test and not the file ([nodejs/node#57672](nodejs/node#57672), first released in 24.0.0). The package scripts passed 30 s and 120 s as per-test limits, so on Node 22 the runner ended a file that ran longer, even when every test in it passed. One correction to the issue text: on Node 22 the flag does not "also" limit the file. It limits only the file, and no test gets a limit from it. - `scripts/node-test.ts` starts `node --test` with the `--test-timeout` value for the running Node major: the per-test limit on Node 24 and later, a file budget on Node 22. It exits with the runner's code and passes SIGINT and SIGTERM on to it. - `test:unit` and `test:integration` in the four packages call it. | Script | Node 24 and later: limit per test | Node 22: budget per file | | ------------------ | --------------------------------- | ------------------------ | | `test:unit` | 30 s | 300 s | | `test:integration` | 120 s | 600 s | - `test/scripts/node-test.test.ts` (added to the root `test` script) runs fixture files with limits of a few seconds: - a file of five passing 500 ms tests, with a 2 s per-test limit, passes on every version; - a slow test is cancelled at the per-test limit on Node 24 and later, and on Node 22 its file is cancelled at the budget; - the script exits 0 on a pass, 1 on a failing test and 2 on an unknown kind of test, and after SIGTERM it ends with the runner's code within 15 s. - `docs/contributor/testing.md` has a new section, "Test time limits": the two meanings, the budgets, the Node pull request, and what to delete when the Node floor moves to 24. `docs/contributor/tooling.md` names the script. - The comments in `packages/hardhat-kms/test/helpers/hardhat-cli.ts` and `tutorial-return-funds.test.ts` match the new numbers. On Node 22 a hung test is now reported as a cancelled file after up to 10 minutes, not as a failed test. The same tests run on Node 24 and 26, where the runner cancels the hung test by name at its limit. Not in scope: the localstack, examples, live and coverage scripts and `scripts/test-hardhat-versions.ts` (CI runs the localstack, examples, coverage and Hardhat-versions jobs on Node 24; the live scripts run locally), and splitting test files. ## Test plan Ran locally on macOS: - `node --test test/scripts/node-test.test.ts` on Node 22.13.0 (with `NODE_OPTIONS='--import tsx'`), 22.23.3, 24.16.0 and 26.0.0, and on 26.0.0 with the `scripts/fail-on-deprecation.mjs` preload: 10 of 10 pass on each. - Four temporary edits to `scripts/node-test.ts`, each reverted, to check that the test fails: - the per-test limit on every version: fails on Node 22.13.0 (the passing file is cancelled); - `>` in place of `>=` in the version rule: fails on Node 24.16.0 (the slow test is no longer cancelled at 1 s); - no exit-code forwarding: fails on Node 24.16.0; - no signal forwarding: fails on Node 22.13.0 and 24.16.0. - `pnpm --filter @hardhat-kms/gcp run test:unit` through the script on Node 22.13.0 (`--import tsx`) and 24.16.0: 93 of 93 pass on each. - `pnpm run test:unit` for the four packages on Node 24.16.0 (the pre-push hook): passes. - `pnpm run check`, `pnpm run docs:check` and `knip` on Node 24.16.0: pass. Not run locally: - The full `pnpm test`, and `test:integration` through the script on any version. The three CI legs (Node 22.13.0, 24.0.0, 26.0.0) run both. - macOS and Windows CI (`ci-all-os.yml`). The script has not run on Windows. - A hang probe in a real integration file (a test that never settles, to see the 600 s file budget end the file on Node 22). The slow-test fixture covers the same path with a 3 s budget. - Ctrl-C in a terminal. SIGTERM forwarding has a test; SIGINT uses the same handler and has none. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
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.
Previously
--test-timeoutis set on per test execution, this is obviously a bug as per test execution is hard to be expected, this patch addresses the issue by settingtimeoutfrom per execution to per test.This patch also fixes a minor issue that
--test-timeoutis not being respected when running without--test.Fixes: #57656