-
Notifications
You must be signed in to change notification settings - Fork 885
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
Multistream should catch Error thrown by thread-stream #1489
Comments
The problem remains: after the worker exits, you won't be able to log anymore and you should crash your process. Currently multistream is not handling the case where one of the destination streams could "crash": would you like to add support for that? I'm ok to get a PR to thread-stream that emits that error synchronously (this is important, otherwise you might get a silent fail on exit) instead of throwing it. |
Thanks for your reply!
I agree but it should crash/restart the worker thread process not the main thread/process right?
Perfect 👍🏻 |
I took a deeper look at the code and it seems that One issue might be that the Maybe we should automatically remove a closed/destroyed ThreadStream from the stream list when we receive a |
Maybe, it would really be up to the user to decide to do so. However It's a PR I'd be willing to review. |
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. |
The
write
function provided bythread-stream
can throw an Error of the worker has exited or is ending:https://github.com/pinojs/thread-stream/blob/9bbbcd196234971c4e546590a496199863447e44/index.js#L213-L219
The multistream is calling
stream.write(data)
without atry/catch
meaning that the Error will propagate:pino/lib/multistream.js
Line 64 in 74893ae
As a result, an error will be thrown by the logger function, for instance
logger.info()
.In my opinion, the logger function should never throw an Error, and even more, when using multi streams where only one stream is "failing".
Alternatively, I think
thread-stream
should not throw an Error but instead emit anerror
to notify that the log cannot be written on this stream.The text was updated successfully, but these errors were encountered: