cluster.worker.on('message', (msg) => ...) fails to register a callback if ESM file extensions is used
未关闭
还没有人认领这个 Issue。
cluster
confirmed-bug
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 272
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用 Node v20.3.1 运行提供的 main.mjs 和 worker.mjs 复现,然后检查涉及 cluster.worker.on('message') 的集群 worker 消息监听器路径。当 worker 使用 .mjs 扩展名时,callback 接收到 worker.send('hello') 发送的消息,并为此情况提供回归测试覆盖,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 描述清楚
- 新手友好度
- 58/100