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

shallow clone target options #1973

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/transport.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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