Confused setTimout behaviour in NodeJS
未关闭
还没有人认领这个 Issue。
timers
- 主要语言
- JavaScript
- 星标
- 122k
- 派生
- 37.4k
- 平均合并
- 4 天 3 小时
- 30 天内合并 PR
- 272
描述
Version
14, 18
Platform
22.2.0 Darwin Kernel arm64
Subsystem
No response
What steps will reproduce the bug?
setTimeout(() => {
console.log('calling 1st timeout')
}, 1)
setTimeout(() => {
console.log('calling 2rd timeout')
}, 0)
// in nodejs
// calling 1st timeout
// calling 2rd timeout
// however, in chrome browser
// calling 2rd timeout
// calling 1st timeout
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior?
Would expect the second time to be called first
What do you see instead?
The first time out is called then the second timeout in NodeJS
Additional information
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先在 Node.js 14 和 18 上运行提供的 setTimeout 重现,然后将其与浏览器结果进行比较。阅读 Node.js 的 setTimeout 和事件循环文档,以确定该顺序是否有规范说明。完成的标准是确定预期顺序,以及 Node.js 的行为是否需要文档或实现方面的更改。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, node.js
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100