v4 crashes with Error: this should not happen: undefined under node --watch on Node.js v26
thread-stream@4.0.0 / pino@10.3.1 / Node.js v26.1.0
With --watch enabled, any 2-target transport setup crashes immediately on startup:
node:events:487
throw er; // Unhandled 'error' event
^
Error: this should not happen: undefined
at Worker.onWorkerMessage (thread-stream/index.js:190:23)
at Worker.emit (node:events:509:20)
at MessagePort.<anonymous> (node:internal/worker:358:14)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:843:20)
at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
Emitted 'error' event on ThreadStream instance at:
at Immediate.<anonymous> (thread-stream/index.js:371:12)
Node.js v26.1.0
Failed running 'index.js'. Waiting for file changes before restarting...
Two targets are required to hit this — pino only spawns a ThreadStream worker when targets.length >= 2.
Minimal repro:
const pino = require('pino')
const logger = pino({
transport: {
targets: [
{
target: 'pino-opentelemetry-transport',
options: { resourceAttributes: { 'service.name': 'repro' } },
level: 'info',
},
{
target: 'pino/file',
options: { destination: 1 },
level: 'info',
},
],
},
})
logger.info('hello world')
setTimeout(() => {}, 60000)
node --watch index.js # crashes (Node.js v26)
Full repro repo
with Docker: https://github.com/Vunovati/repro-pino-otel
| Node.js |
--watch |
result |
| v24 |
yes |
✅ works |
| v26 |
no |
✅ works |
| v26 |
yes |
❌ crashes |
Node.js v26 is not yet in the pino CI matrix — flagging this as a heads-up ahead of that.
Possible cause
Node.js v26 landed nodejs/node#62368 ("watch: track worker entry files in watch mode"), which sends messages through the worker's parentPort without a code field.
I believe this breaks thread-stream's onWorkerMessage where it finds msg.code === undefined index.js#L190.
v4 crashes with
Error: this should not happen: undefinedundernode --watchon Node.js v26thread-stream@4.0.0 / pino@10.3.1 / Node.js v26.1.0
With
--watchenabled, any 2-target transport setup crashes immediately on startup:Two targets are required to hit this — pino only spawns a ThreadStream worker when
targets.length >= 2.Minimal repro:
node --watch index.js # crashes (Node.js v26)Full repro repo
with Docker: https://github.com/Vunovati/repro-pino-otel
--watchNode.js v26 is not yet in the pino CI matrix — flagging this as a heads-up ahead of that.
Possible cause
Node.js v26 landed nodejs/node#62368 ("watch: track worker entry files in watch mode"), which sends messages through the worker's
parentPortwithout acodefield.I believe this breaks thread-stream's
onWorkerMessagewhere it findsmsg.code === undefinedindex.js#L190.