v3: backport #213 (ignore Node --watch worker messages)#221
Closed
zanlucathiago wants to merge 1 commit into
Closed
v3: backport #213 (ignore Node --watch worker messages)#221zanlucathiago wants to merge 1 commit into
zanlucathiago wants to merge 1 commit into
Conversation
Node 24.16 (which backports nodejs/node#62368 'watch: track worker entry files in --watch mode') sends internal tracking messages over parentPort that don't carry the thread-stream protocol code. The default branch in onWorkerMessage then throws 'this should not happen: undefined' and kills the process. The 4.x line was fixed in pinojs#213 (released as 4.1.0); this is the same patch applied on top of v3.1.0 so users on pino@9, which still pins thread-stream ^3.0.0, don't have to ship a package manager override. Refs pinojs#220.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Heads up before reviewing: this PR is built on top of
v3.1.0, not onmain. GitHub's diff againstmainwill look noisy because the 4.x line moved on. The actual change is the single commit a177143 — feel free to cherry-pick it onto av3.xmaintenance branch and close this PR.Backports #213 to the 3.x line. Same one-liner in
onWorkerMessageplus the regression test, just expressed withtapto match how v3 tests are written.Why
Node 24.16 shipped on 2026-05-21 with the backport of nodejs/node#62368 (
watch: track worker entry files in --watch mode). Once--watchis active, the runtime starts sending tracking messages overparentPortwithout the protocolcodefield thread-stream looks for. The default branch in the switch then throwsError: this should not happen: undefinedand kills the process on the first tick.This is the exact case #212 reported on Node 26 and #213 fixed in 4.1.0. The 3.x line never picked the fix — last release on that branch is
3.1.0from June 2024 — so anyone still onpino@9(which pinsthread-stream: ^3.0.0) breaks on a fresh install the moment they upgrade Node.pino-prettybumps don't help because the dep flows through pino itself.Full incident write-up is in #220 with timeline and repro.
What's in the diff
index.js: bail out early when the message has nocode, before hitting theswitch.test/watch-mode.test.js+test/message-without-code.js: the regression test from fix: ignore watch mode worker messages #213, ported totap(the v3 line still usestap, notnode:test).README.md: short note that messages without acodeare ignored, so people writing custom worker events aren't confused.CI workflow is intentionally untouched — didn't want to widen the scope.
Test
Full suite was a bit flaky locally on unrelated tests, same as I see on green CI runs for
main, so I limited my run to the new test plusbase.test.js, both green.Workaround in the meantime
For anyone landing here from Google:
pnpm.overrides(or npmoverrides) forcingthread-stream: ^4.0.0works. But that's not exactly something users would guess from the stack trace alone, which is the motivation for cutting a 3.x patch.Refs #220.