-
Notifications
You must be signed in to change notification settings - Fork 892
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Call .end() on thread-stream before exiting the process. (#1296)
- Loading branch information
Showing
5 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use strict' | ||
|
||
const fs = require('fs') | ||
const { once } = require('events') | ||
const { Transform } = require('stream') | ||
|
||
async function run (opts) { | ||
if (!opts.destination) throw new Error('kaboom') | ||
const stream = fs.createWriteStream(opts.destination) | ||
await once(stream, 'open') | ||
const t = new Transform({ | ||
transform (chunk, enc, cb) { | ||
setImmediate(cb, null, chunk.toString().toUpperCase()) | ||
} | ||
}) | ||
t.pipe(stream) | ||
return t | ||
} | ||
|
||
module.exports = run |
16 changes: 16 additions & 0 deletions
16
test/fixtures/transport-exit-immediately-with-async-dest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
const pino = require('../..') | ||
const transport = pino.transport({ | ||
target: './to-file-transport-with-transform.js', | ||
options: { | ||
destination: process.argv[2] | ||
} | ||
}) | ||
const logger = pino(transport) | ||
|
||
logger.info('Hello') | ||
|
||
logger.info('World') | ||
|
||
process.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ const transport = pino.transport({ | |
const logger = pino(transport) | ||
|
||
logger.info('Hello') | ||
|
||
process.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters