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

sometimes dead loop #54

Closed
loynoir opened this issue Oct 16, 2023 · 5 comments
Closed

sometimes dead loop #54

loynoir opened this issue Oct 16, 2023 · 5 comments

Comments

@loynoir
Copy link

loynoir commented Oct 16, 2023

Version

When

  • sometimes, not reproducible

Error

  • 100% CPU, guess somehow dead loop

  • After Ctrl-C

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> (/home/vscode/.yarn/berry/cache/foreground-child-npm-2.0.0-80c976b61e-8.zip/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.0

Related

Maybe caused by below line.

process.exitCode = signal ? 128 + signal : code

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/39359c8466846541b5b3298165ef79c509f0cd09/types/node/child_process.d.ts#L532

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/39359c8466846541b5b3298165ef79c509f0cd09/types/node/v16/process.d.ts#L63-L100

The signal should be null or some const string.

@loynoir
Copy link
Author

loynoir commented Nov 11, 2023

Although node v21 seems no c8 sometimes hangs forever problem, but according to the types, should leave it open.

@SSANSH
Copy link

SSANSH commented Jan 23, 2024

+1

@nwalters512
Copy link

nwalters512 commented Jan 29, 2024

@isaacs I'm willing to open a PR to fix this, I'd like to understand the intention behind the close handler though. I can't see how this ever worked, since (from what I can tell) the second argument to the close handler has always been a string, so this certainly never would have done what it seems like it was supposed to. My guess is this became an error as of nodejs/node#43716.

There are at least two approaches we could take to fix this:

I lean towards the second option with human-signals, but I'd appreciate input from a maintainer before I open a PR. EDIT: My guess is that if we want maximum backwards-compatibility, we should use the first option and set process.exitCode = 128, since I think that is what 128SIGINT would have been coerced to.

@isaacs
Copy link
Member

isaacs commented Jan 29, 2024

No pull request is needed. This is already working fine on v3, the bug is only in v2. The PR needs to be made to the consumers of fg child.

@isaacs isaacs closed this as completed Jan 29, 2024
@nwalters512
Copy link

Thanks for letting me know, I didn't check whether the link in OP's issue corresponded to the latest version of foreground-child 🤦

I'll PR the latest version into nyc. Thanks again (and thanks as always for maintaining so much of the Node ecosystem ❤️)

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

No branches or pull requests

4 participants