-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Given this snippet:
const transport = pino.transport({
targets: [
{
target: 'pino-pretty',
level: 'debug',
},
{
target: 'pino-socket',
level: 'debug',
options: {
address: 'localhost',
port: '10000',
mode: 'tcp',
reconnect: false,
},
},
],
});
const logger = pino(
{
level: 'debug',
name: 'pino-socket-test',
timestamp: pino.stdTimeFunctions.isoTime,
},
transport,
);
logger.info('first log');
setInterval(() => {
logger.info('interval log');
}, 5 * 1000);If my TCP server is running on localhost port 10000, all is working correctly.
Problem:
- But if I stop the server and then run this script, then I get this error in the console:
Error: the worker has exited
And my script exists.
- If I set reconnecting to true instead, my script just hangs and never logs anything.
Solution:
If I remove the wait for the connection to open:
pino-socket/lib/pino-transport.js
Line 36 in 903f790
| await once(connection, 'open') |
Then other transports, in this case pino-pretty, can start logging in both cases, and no error occurs.
Can this be removed or at least be configurable?
Metadata
Metadata
Assignees
Labels
No labels