cluster.worker.on('message', (msg) => ...) fails to register a callback if ESM file extensions is used
Chưa có ai nhận issue này.
- 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
v20.3.1
Platform
All supported platform
Subsystem
No response
What steps will reproduce the bug?
After a migration of code to ESM by using .mjs file extensions, the poolifier project has encountered issues at running internal benchmarks code.
Test case:
- main.mjs:
import cluster from 'cluster'
cluster.setupPrimary({ exec: './worker.mjs' })
const worker = cluster.fork()
worker.on('message', message => {
console.info('message received from worker:', message)
})
worker.on('online', () => {
console.info('worker is online')
})
worker.on('error', (error) => {
console.info('worker error', error)
})
worker.on('disconnect', () => {
console.info('worker disconnected')
})
worker.on('exit', () => {
console.info('worker exited')
})
worker.send('hello')
- worker.mjs:
import cluster from 'cluster'
cluster.worker.on('message', message => {
console.info('echo message received from main:', message)
cluster.worker.send(message)
})
node main.mjs is frozen.
How often does it reproduce? Is there a required condition?
100% reproducible
What is the expected behavior? Why is that the expected behavior?
No response
What do you see instead?
Callback is never called if a message is sent from the primary.
Additional information
No response
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- 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 chạy bản tái hiện được cung cấp với main.mjs và worker.mjs bằng Node v20.3.1, sau đó kiểm tra đường dẫn trình lắng nghe thông báo của cluster worker liên quan đến cluster.worker.on('message'). Hoàn tất khi callback nhận được thông báo do worker.send('hello') gửi khi worker sử dụng phần mở rộng .mjs, cùng với kiểm thử hồi quy cho trường hợp này.
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
- backend
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 58/100