test(npm): one bounded, diagnosable way to run npm, and quiet npm env on every test spawn (#1130) - #1135
Merged
Conversation
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>
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.
Problem and change
#1130: on Windows / Node 24 CI,
test/prepare.test.ts'snpm pack --ignore-scripts --jsonprinted its complete JSON but did not exit within 30 seconds (status null).Evidence:
process.execPathplusnpm_execpath, with nonpm.cmdand no shell.--jsonarray at the very end ofnpm.exec, so npm had finished its work and was stuck in or after its exit step.--ignore-scriptsstarts no child processes.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:
scripts/npm-command.ts(npmSpawn,runNpmSync,assertNpmSucceeded,quietNpmEnv). It always uses npm's JavaScript entry under the current Node, with no shell, no stdin andwindowsHide. The update notifier, fund, audit and progress output are switched off in the child's environment.npm.cmd-through-a-shell fallbacks now go through the helper:test/addons.integration.tstest/private-requests.integration.tstest/authjs-provider.integration.tsscripts/workspaces.tsdocs/CI.mddescribes the helper and how to repeat the test in a Windows loop.Verification
test/npm-command.test.ts: the spawn arguments and environment (deterministic, no network), the failure message including truncation, and one realnpm --versionrun.npm run verifyexits 0. Core: 1417 pass, and every workspace and integration suite passes.npm run test:packageexits 0.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