nodejs / nodejs/node

Confused setTimout behaviour in NodeJS

オープン
#46,596 コメント 17 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

timers
主要言語
JavaScript
スター
122k
フォーク
37.3k
平均マージ
4日 2時間
マージ済み PR(30日)
283

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供されている setTimeout の再現コードを Node.js 14 と 18 で実行し、その後ブラウザーの結果と比較します。Node.js の setTimeout とイベントループのドキュメントを読み、順序が規定されているかどうかを判断します。期待される順序と、Node.js の動作にドキュメントまたは実装の変更が必要かどうかを明らかにできれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, node.js
領域
backend
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。