Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

watch mode triggers unsolicided messages to Workers

未關閉
#65,044 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
55/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
javascript, node.js
領域
backend

研究方向

首先使用 main.mjs、worker.js 和 node --watch 執行已回報的重現步驟,然後追蹤發出 "watch:require" 訊息的 worker 與 watch 模式處理邏輯。完成的標準是:在此情況下 worker 不會收到任何非請求訊息,並且針對這個始終可重現的行為具備回歸測試涵蓋。

由索引模型根據 Issue 內容生成。

描述

Version

24.19.0, 26.6.0

Platform
Linux 05338a186e89 6.18.33.1-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Fri Jun  5 01:12:21 UTC 2026 x86_64 Linux
Subsystem

worker

What steps will reproduce the bug?

given the following two files:

// main.mjs
import { Worker } from 'worker_threads'
const worker = new Worker('./worker.js')
worker.on('message', console.log)
// worker.js (can be empty)

it can be reproduced using node --watch main.mjs.

The behavior is identical when using an equivalent main.cjs instead.

How often does it reproduce? Is there a required condition?

reproduces consistently

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

applications should not receive unexpected (and undocumented) messages by the engine.

What do you see instead?

Unsolicided "watch:require" messages are sent.

Additional information

This issue effects v24 and v26, as can be seen in the following log (tested with node.js v22.23.1, v23.11.1, v24.19.0, v25.9.0, v26.6.0; note that I aborted each run with ctrl+c)

$ docker run --rm -v .:/app -w /app node:22-alpine   node --watch main.mjs
Completed running 'main.mjs'. Waiting for file changes before restarting...

$ docker run --rm -v .:/app -w /app node:23-alpine   node --watch main.mjs                                                 
Completed running 'main.mjs'                  

$ docker run --rm -v .:/app -w /app node:24-alpine   node --watch main.mjs
{ 'watch:require': [ '/app/worker.js' ] }
Completed running 'main.mjs'. Waiting for file changes before restarting...

$ docker run --rm -v .:/app -w /app node:25-alpine   node --watch main.mjs
Completed running 'main.mjs'. Waiting for file changes before restarting...

$ docker run --rm -v .:/app -w /app node:26-alpine   node --watch main.mjs
{ 'watch:require': [ '/app/worker.js' ] }
Completed running 'main.mjs'. Waiting for file changes before restarting...

Though robust message handling code should always validate and check received messages, such unexpected messages can lead to unexpected behavior, e.g. crashes. This unexpected node.js behavior leads to the following issue downstream with an XML schema validating library: https://github.com/noppa/xmllint-wasm/issues/37

主要語言
JavaScript
星號
122k
分支
37.4k
平均合併
4 天 2 小時
30 天內合併 PR
277

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

nodejs/node 的其他 Issue

查看 nodejs/node 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。