diff --git a/lib/transport.js b/lib/transport.js index b8ce347f2..8ecd21952 100644 --- a/lib/transport.js +++ b/lib/transport.js @@ -71,7 +71,11 @@ function flush (stream) { } function transport (fullOptions) { - const { pipeline, targets, levels, dedupe, options = {}, worker = {}, caller = getCallers() } = fullOptions + const { pipeline, targets, levels, dedupe, worker = {}, caller = getCallers() } = fullOptions + + const options = { + ...fullOptions.options + } // Backwards compatibility const callers = typeof caller === 'string' ? [caller] : caller diff --git a/test/transport/core.test.js b/test/transport/core.test.js index b8af6738d..a61b0853d 100644 --- a/test/transport/core.test.js +++ b/test/transport/core.test.js @@ -466,6 +466,26 @@ test('sets worker data informing the transport that pino will send its config', instance.info('hello') }) +test('sets worker data informing the transport that pino will send its config (frozen file)', ({ match, plan, teardown }) => { + plan(1) + const config = { + transport: { + target: join(__dirname, '..', 'fixtures', 'transport-worker-data.js'), + options: {} + } + } + Object.freeze(config) + Object.freeze(config.transport) + Object.freeze(config.transport.options) + const instance = pino(config) + const transport = instance[pino.symbols.streamSym] + teardown(transport.end.bind(transport)) + transport.once('workerData', (workerData) => { + match(workerData.workerData, { pinoWillSendConfig: true }) + }) + instance.info('hello') +}) + test('stdout in worker', async ({ not }) => { let actual = '' const child = execa(process.argv[0], [join(__dirname, '..', 'fixtures', 'transport-main.js')])