-
Notifications
You must be signed in to change notification settings - Fork 883
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
When having single transport in pipelining the worker exit in the middle #1774
Comments
Why are you using a transport in tests to do nothing? You can just set the log level extremely high and nothing will be logged. |
in our code, we have transport that changes some stuff on the payload (in this example, I made the transport do nothing for the sake of the reproduction), and depending on configuration we add more transports (console or UDP) if our tests we disable both console and UDP so we only left with that first transport |
I'm not sure what the fix for this would be. You are creating a transport that yield data with no actual destination, what do you think pino should do in this case? |
I think it should either warn about this or drop the data, Why does it work with 2 targets that are the same? FYI, even when we don't |
I think a better error message for this. Using pipelining must require at least 2 streams. Take a look at this Line 28 in 1aacfd2
pipeline function would be called with only one stream, erroring.
Would you like to send a PR? |
Should it log/throw error if the only stream is writable (or don't emit data to the next)? |
Yes it should throw an error in this case |
wouldn't this be a breaking change? |
It does not seem the code is working at all right now, what will it break? |
I just checked and this will be a breaking change as when the transport consumes the data everything work: Example: const pino = require('pino');
const fs = require('fs');
fs.writeFileSync('./to-file-transport.js', `
'use strict'
const fs = require('fs')
const { once } = require('events')
async function run (opts) {
if (!opts.destination) throw new Error('kaboom')
const stream = fs.createWriteStream(opts.destination)
await once(stream, 'open')
return stream
}
module.exports = run
`);
let outputPath = './file-output.js'
fs.writeFileSync(outputPath, '')
const transport = pino.transport({
pipeline: [{
target: './to-file-transport.js',
options: { destination: outputPath }
}]
})
const instance = pino(transport)
setInterval(() => {
const output = (fs.readFileSync(outputPath)).toString();
console.log(output)
}, 1000);
async function run() {
while(true) {
instance.info({ hello: 'world' }, 'hello')
await new Promise(resolve => setTimeout(resolve, 1))
}
}
run(); Also when not using the |
Sure, but this transport results in a The question is finding out exactly why the worker is crashing and then intercepting this condition early. |
This transport will now fail when it wasn't before (as it returns a '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 |
and it will break (use this with the PR and see it's failing) const pino = require("pino");
const { setTimeout } = require("timers/promises");
const log = pino({
level: "info",
transport: {
pipeline: [
{
target: "pino-pretty",
options: { destination: 1 } // use 2 for stderr
},
],
},
});
async function run() {
let i = 0;
while (true) {
log.info(`Hello World! ${i++}`);
await setTimeout(1);
}
}
run(); |
I don't understand then why your example at the top fails while pino-pretty does not have this problem. |
that's the question, yesterday I debugged it for hours and maybe it's related to the fact the and |
Fixed by emitting a warning in thread-stream |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I know pipelining is intended to have multiple transports but in our tests, we sometimes don't have transport and only have our transformer as a transport.
Reproduction:
Given this code:
and this transport :
I get:
The workaround is to add another proxy transport...
The text was updated successfully, but these errors were encountered: