pino
pino copied to clipboard
Allow worker thread to emit custom event back to parent
The current worker thread only allow event with "READY" and "ERROR" and any other events will get remove. Wonder if it is possible to allow other event to propagate back instead of stripping off?
The current use case is to allow propagation of error object back to the main process but when we emit "error" event or throw error the worker thread will terminate immediately which will cause the main process to terminate for subsequent logging attempt.
https://github.com/pinojs/thread-stream/blob/main/index.js#L138-L164
What other signals do logger threads need?
Sorry for the late reply, was thinking adding a new signal "MESSAGE" to have the flexibility to allow worker thread to communicate with the parent instead of one way communicate, although I am not sure if this is against the Pino's design philosophy.
The other option I have is to allow to have some flag along with the "ERROR" signal to prevent the stream being destroyed as currently whenever the stream emit an error, the stream will get destroy. Thought it could be useful to post the non-destructive error signal back to the parent.
What are the use cases for these changes?
@TAYTS Did you manage to resolve this?
I've had success with this by posting an object message with the code property set to 'EVENT' and set an arbitrary name property and any data I need passed to the data property