nodejs / nodejs/node

child_process: ERR_INVALID_ARG_TYPE on .kill()

Open
#30,702 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

child_process stale
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

  • Version: Electron v4.2.12 - Node v10.11.0
  • Platform: Windows 10 64-bit
  • Subsystem: child_process

We are getting the following stack trace when killing a child_process:

root ERROR TypeError [ERR_INVALID_ARG_TYPE]: The "err" argument must be of type number. Received type undefined
    at validateNumber (internal/validators.js:130:11)
    at Object.getSystemErrorName (util.js:1435:3)
    at errnoException (internal/errors.js:303:21)
    at ChildProcess.kill (internal/child_process.js:430:26)

From what I can make of it, it seems to be caused by the following code:

https://github.com/nodejs/node/blob/v10.x/lib/internal/child_process.js#L425-L439

    var err = this._handle.kill(signal);
    if (err === 0) {
      /* Success. */
      this.killed = true;
      return true;
    }
    if (err === UV_ESRCH) {
      /* Already dead. */
    } else if (err === UV_EINVAL || err === UV_ENOSYS) {
      /* The underlying platform doesn't support this signal. */
      throw errnoException(err, 'kill');
    } else {
      /* Other error, almost certainly EPERM. */
      this.emit('error', errnoException(err, 'kill'));
    }

Somehow, err seems to be undefined, making us land in the last else branch, but then errnoException doesn't know what to make out of it and throws the error that we see.

The issue only happens in Electron, so it might not be entirely related to Node, but I was wondering if this err value is expected to be undefined in some circumstance?

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 with the referenced range in lib/internal/child_process.js and trace the err value from this._handle.kill(signal) through internal/errors.js, util.js, and internal/validators.js. Reproduce the .kill() failure on Windows with the reported Electron and Node versions, then determine the platform condition that produces undefined and document or test the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.