npm / npm/cli

[BUG] Tests crash out on ctrl-c

Open
#6,766 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2 Release 10.x Release 9.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Is there an existing issue for this?
  • I have searched the existing issues
This issue exists in the latest npm version
  • I am using the latest npm
Current Behavior

Interrupting tests with ctrl-c results in an error:

TypeError: The "code" argument must be of type number. Received type string ('128SIGINT')
at process.set [as exitCode] (node:internal/bootstrap/node:123:9)
at ChildProcess. (/Users/dan/Source/npm-cli/node_modules/nyc/node_modules/foreground-child/index.js:63:22)
at ChildProcess.emit (node:events:514:28)
at ChildProcess.emit (node:domain:489:12)
at maybeClose (node:internal/child_process:1105:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:305:5)

This seems to come from bad logic adding a number to a string in foreground-child@2.0.0 (outdated) via nyc@15.1.0 (latest, but unmaintained).

Expected Behavior

Tests should exit cleanly.

Steps To Reproduce
  1. In Mac or Windows
  2. Run npm test
  3. Use ctrl-c to abort the tests
  4. Observe error
Environment
  • npm: 10.0.0
  • Node.js: 20.6.0
  • OS Name: macOS
  • System Model Name: Macbook Air
  • npm config:
; "builtin" config from /opt/homebrew/lib/node_modules/npm/npmrc

prefix = "/opt/homebrew" 

; "user" config from /Users/dan/.npmrc

auto-install-peers = true 

; "project" config from /Users/dan/Source/npm-cli/.npmrc

package-lock = true 

; node bin location = /opt/homebrew/Cellar/node/20.6.0/bin/node
; node version = v20.6.0
; npm local prefix = /Users/dan/Source/npm-cli
; npm version = 9.8.1
; cwd = /Users/dan/Source/npm-cli
; HOME = /Users/dan
; Run `npm config ls -l` to show all defaults.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running npm test and reproducing the ctrl-c failure on the reported platforms. Inspect the nyc@15.1.0 dependency path and the linked foreground-child index.js logic; done means interrupting the test run exits cleanly without the TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.