Skip to content

test(npm): one bounded, diagnosable way to run npm, and quiet npm env on every test spawn (#1130) - #1135

Merged
jimhoyd merged 1 commit into
mainfrom
fix/windows-npm-pack-hang
Oct 1, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
fix/windows-npm-pack-hang

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Problem and change

#1130: on Windows / Node 24 CI, test/prepare.test.ts's npm pack --ignore-scripts --json printed its complete JSON but did not exit within 30 seconds (status null).

Evidence:

  • The test already ran npm as process.execPath plus npm_execpath, with no npm.cmd and no shell.
  • npm 11 writes the --json array at the very end of npm.exec, so npm had finished its work and was stuck in or after its exit step.
  • The update notifier skips CI, so it wasn't running.
  • --ignore-scripts starts no child processes.
  • The runner was heavily loaded: neighbouring tests took 11–16 seconds.

The root cause is not proven. This PR does not raise the timeout. It removes the plausible causes and makes the next failure say what happened:

  • One shared way to run npm, in scripts/npm-command.ts (npmSpawn, runNpmSync, assertNpmSucceeded, quietNpmEnv). It always uses npm's JavaScript entry under the current Node, with no shell, no stdin and windowsHide. The update notifier, fund, audit and progress output are switched off in the child's environment.
  • Diagnosable timeouts: the message gives the command and directory, status, signal, whether the timeout fired, elapsed time against the limit, any spawn error, and the last 20 lines of stderr and stdout. The prepare test also logs each npm call's elapsed time, so CI collects Windows timings.
  • The same launch everywhere: the remaining npm.cmd-through-a-shell fallbacks now go through the helper:
    • test/addons.integration.ts
    • test/private-requests.integration.ts
    • test/authjs-provider.integration.ts
    • scripts/workspaces.ts
  • Docs: docs/CI.md describes the helper and how to repeat the test in a Windows loop.

Verification

  • New tests in test/npm-command.test.ts: the spawn arguments and environment (deterministic, no network), the failure message including truncation, and one real npm --version run.
  • Targeted tests: npm-command, prepare, docs-search-package and release-publish ran 17 tests, all passing.
  • npm run verify exits 0. Core: 1417 pass, and every workspace and integration suite passes.
  • npm run test:package exits 0.
  • Not tested on Windows. It runs there only in this PR's CI.

Refs #1130. The issue stays open until Windows CI shows the hang is gone, or the new diagnostics show its cause.

🤖 Generated with Claude Code

The Windows Node 24 failure in #1130 (test/prepare.test.ts, npm pack
--ignore-scripts --json) printed its complete pack JSON and was then
killed by spawnSync's 30 s timeout, reported only as `null !== 0`.

scripts/npm-command.ts gains runNpmSync/npmSpawn/describeNpmRun: npm's
JavaScript entry under this Node (no npm.cmd, no shell), stdin ignored,
windowsHide, and npm_config_update_notifier/fund/audit/progress forced
off, so nothing beyond the command is left for the child to finish. A
failure names status, signal, whether the timeout fired, elapsed time
and the tails of stderr and stdout. prepare.test.ts and
docs-search-package.test.ts use it and log each npm call's elapsed time
as a test diagnostic; the timeouts are unchanged.

The remaining npm.cmd-through-a-shell fallbacks (addons, private-requests
and authjs-provider integration tests, scripts/workspaces.ts run) now go
through npmCommand, so every npm the repository spawns is started the
same way. docs/CI.md records the helper and how to repeat the test.

Refs #1130

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jimhoyd
jimhoyd merged commit 592a90d into main Oct 1, 2026
24 checks passed
@jimhoyd
jimhoyd deleted the fix/windows-npm-pack-hang branch October 1, 2026 22:17
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