Worker options for custom transport in pipeline not passed
thyming opened this issue · 1 comments
thyming commented
Hi, thanks for your work on pino!
I am trying to create a pipelined transport and pass it a message port, like so:
import pino, { TransportPipelineOptions } from 'pino';
import { MessageChannel } from 'node:worker_threads';
const { port1, port2 } = new MessageChannel();
const logger = pino({
transport: {
pipeline: [
{
target: './transport.ts',
worker: {
workerData: {
port: port1,
},
transferList: [port1],
},
},
{
target: 'pino-pretty',
options: {
sync: true,
translateTime: 'HH:MM:ss Z',
ignore: 'pid,hostname',
},
},
],
} satisfies TransportPipelineOptions,
});
When I run this code, it throws this error:
TypeError: Object that needs transfer was found in message but not listed in transferList
32 | port: port1,
33 | },
> 34 | transferList: [port1],
| ^
35 | },
36 | },
However, if I do not use a pipeline (omitting the pino-pretty transport) and create the transport like so
pino(
pino.transport({
target: './transport.ts',
worker: {
workerData: {
port: port1,
},
transferList: [port1],
},
}),
);
everything works correctly.
Is there potentially an option I'm not passing or passing incorrectly to make this work with a pipeline?
Thanks!
mcollina commented
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.