nodejs / nodejs/node

watch: `NODE_OPTIONS=--watch` causes infinite loop

Đang mở
#61,740 7 bình luận 1 reaction 0 người được giao Xem trên GitHub

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

confirmed-bug watch-mode
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

v25.6.0

Platform
Darwin <redacted> 24.6.0 Darwin Kernel Version 24.6.0: Wed Nov  5 21:33:58 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6000 arm64 arm Darwin
Subsystem

No response

What steps will reproduce the bug?
  1. Write the following to test.js and make it executable:
    #!/usr/bin/env node
    console.log('hello');
    
  2. NODE_OPTIONS="--watch" ./test.js
How often does it reproduce? Is there a required condition?

This is always reproducible.

What is the expected behavior? Why is that the expected behavior?

I would expect it to run normally, producing hello in stdout and then exiting.

What do you see instead?

There is no output. I can see in my process list that there are hundreds of node processes spawning.

Additional information

This seems to be the same issue as https://github.com/nodejs/node/issues/51159. For additional context, my intent was to reuse a bin entrypoint in package.json but with --watch mode, so under the scripts field it looked roughly like:

"scripts": {
    "dev": "NODE_OPTIONS='--watch' app",
}

...where app is in node_modules/.bin/.

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 bằng cách tái hiện lệnh của executable entrypoint với NODE_OPTIONS="--watch" và so sánh nó với issue #51159. Theo dõi cách executable và package bin entrypoint được xử lý trong watch mode, sau đó thêm hoặc cập nhật một regression test; hoàn thành khi lệnh in hello một lần rồi thoát mà không tạo process.

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, node.js
Lĩnh vực
cli, developer-experience
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
Khá rõ ràng
Mức phù hợp với người mới
55/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.