Skip to content

Commit

Permalink
shallow clone target options (#1973)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed May 13, 2024
1 parent 75e5591 commit 206edee
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/transport.js
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions test/transport/core.test.js
Expand Up @@ -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')])
Expand Down

0 comments on commit 206edee

Please sign in to comment.