Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node v20: TypeError [ERR_INVALID_ARG_TYPE]: The "code" argument must be of type number. Received type string ('128SIGINT') #1535

Closed
2 tasks done
anishkny opened this issue Oct 18, 2023 · 6 comments · Fixed by #1546

Comments

@anishkny
Copy link

anishkny commented Oct 18, 2023

Link to bug demonstration repository

https://github.com/anishkny/nyc-bug-demo

Expected Behavior

Upon pressing Ctrl-C program should exit and coverage information should be generated.

Observed Behavior

npm start

> start
> nyc node index.js

Server running at http://127.0.0.1:3000/
^Cnode:internal/validators:95
      throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
      ^

TypeError [ERR_INVALID_ARG_TYPE]: 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.<anonymous> (/Users/anish/workspace/nyc-bug-demo/node_modules/foreground-child/index.js:63:22)
    at ChildProcess.emit (node:events:514:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v20.8.1

Troubleshooting steps

  • Does not happen in Node v18.
  • Does not happen if just running server node index.js without nyc

Environment Information

$ npx envinfo@latest --preset nyc
Need to install the following packages:
[email protected]
Ok to proceed? (y)

  System:
    OS: macOS 14.0
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 132.84 MB / 16.00 GB
  Binaries:
    Node: 20.8.1 - /usr/local/bin/node
    npm: 10.1.0 - /usr/local/bin/npm
  npmPackages:
    nyc: ^15.1.0 => 15.1.0
@anishkny anishkny changed the title TypeError [ERR_INVALID_ARG_TYPE]: The "code" argument must be of type number. Received type string ('128SIGINT') Node v20: TypeError [ERR_INVALID_ARG_TYPE]: The "code" argument must be of type number. Received type string ('128SIGINT') Oct 18, 2023
@anishkny
Copy link
Author

anishkny commented Nov 8, 2023

Any updates on this? Is this accepted as a pretty severe bug now that Node.js 20 is the current active release?

@SSANSH
Copy link

SSANSH commented Jan 23, 2024

maybe the main solution will be to bump from foreground-child 2.0.0 to latest version. issue is duplicated here sometimes dead loop · Issue #54 · tapjs/foreground-child · GitHub

@nwalters512
Copy link
Contributor

I also witnessed this on Node 20, indeed it seems to be an issue with foreground-child incorrectly treating a string as a number. There are a few options for a fix; I asked the maintainer which he'd prefer: tapjs/foreground-child#54 (comment)

@nwalters512
Copy link
Contributor

Turns out this is already fixed in the latest version of foreground-child. I opened #1546 to upgrade the package.

@kraenhansen
Copy link

kraenhansen commented Apr 18, 2024

Another reproduction:

npm install [email protected] segfault-handler
npx nyc -- node -e 'require("segfault-handler").causeSegfault()'

@YoshikiShibata
Copy link

When I tried to the nyc process with TERM signal, I got the following error:

TypeError: The "code" argument must be of type number. Received type string ('128SIGTERM')
    at process.set [as exitCode] (node:internal/bootstrap/node:123:9)
    at ChildProcess.<anonymous> (/home/runner/work/shiki-api/shiki-api/node_modules/nyc/node_modules/foreground-child/index.js:63:22)
    at ChildProcess.emit (node:events:518:28)
    at ChildProcess.emit (node:domain:488:12)
    at maybeClose (node:internal/child_process:1105:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:305:5) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants