events: getMaxListeners ignores setMaxListeners

未关闭 适合新手
#67,916 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
69/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
api, backend

调研方向

首先追踪 Node.js 的 events 实现中的 getMaxListeners 和 setMaxListeners,然后检查 MessagePort 监听器数量限制相关的测试。使用提供的 node:events 示例复现报告的问题,并添加一个回归测试,证明设置后 getMaxListeners(port1) 返回 2。回归测试通过且现有事件测试继续全部通过,即为完成。

由索引模型根据 Issue 内容生成。

描述

Version

v26.13.0

Platform
Microsoft Windows NT 10.0.19045.0 x64
Subsystem

events

What steps will reproduce the bug?
import { getMaxListeners, setMaxListeners } from 'node:events';

const { port1 } = new MessageChannel();
setMaxListeners(2, port1);
console.log(getMaxListeners(port1));
How often does it reproduce? Is there a required condition?

always, no condition

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

it should print 2

What do you see instead?

it prints 10 (default number of listeners)

Additional information

No response

主要语言
JavaScript
星标
124k
派生
38k
平均合并
4 天 2 小时
30 天内合并 PR
266

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

nodejs/node 的其他 Issue

查看 nodejs/node 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。