Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worker options for custom transport in pipeline not passed #1856

Open
thyming opened this issue Nov 30, 2023 · 1 comment
Open

Worker options for custom transport in pipeline not passed #1856

thyming opened this issue Nov 30, 2023 · 1 comment
Labels

Comments

@thyming
Copy link

thyming commented Nov 30, 2023

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
Copy link
Member

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

@mcollina mcollina added the bug label Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants