nodejs / nodejs/node

child_process: ERR_INVALID_ARG_TYPE on .kill()

Aperta
#30,702 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

child_process stale
Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

  • 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?

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con l’intervallo indicato in lib/internal/child_process.js e segui il valore err da this._handle.kill(signal) attraverso internal/errors.js, util.js e internal/validators.js. Riproduci il fallimento di .kill() su Windows con le versioni di Electron e Node riportate, quindi determina la condizione della piattaforma che produce undefined e documenta o testa il comportamento previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
operating-systems
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Da chiarire
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.