nodejs / nodejs/node

child_process: ERR_INVALID_ARG_TYPE on .kill()

Đang mở
#30,702 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

child_process stale
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.3k
Merge trung bình
4 ngày 2 giờ
Pull request đã merge (30 ngày)
283

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với phạm vi được tham chiếu trong lib/internal/child_process.js và lần theo giá trị err từ this._handle.kill(signal) qua internal/errors.js, util.js và internal/validators.js. Tái hiện lỗi .kill() trên Windows với các phiên bản Electron và Node được báo cáo, sau đó xác định điều kiện nền tảng tạo ra undefined và ghi lại hoặc kiểm thử hành vi mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript
Lĩnh vực
operating-systems
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
42/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.