nodejs / nodejs/node

child_process: ERR_INVALID_ARG_TYPE on .kill()

Abierto
#30,702 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

child_process stale
Lenguaje dominante
JavaScript
Estrellas
122k
Forks
37.3k
Merge medio
4 d 2 h
PR fusionados (30 d)
283

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con el rango referenciado en lib/internal/child_process.js y sigue el valor err desde this._handle.kill(signal) a través de internal/errors.js, util.js e internal/validators.js. Reproduce el fallo de .kill() en Windows con las versiones de Electron y Node indicadas; después determina la condición de plataforma que produce undefined y documenta o prueba el comportamiento esperado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
operating-systems
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Activo
Claridad
Necesita aclaración
Aptitud para principiantes
42/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.