-
Notifications
You must be signed in to change notification settings - Fork 50
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
Error: write after end
when handling SIGINT
#502
Comments
I played around with this to see if I could get past the error. Changing nodejs-logging-winston/src/index.ts Line 182 in 8bc9aad
to this.common.log(info[LEVEL] || level, message, metadata || {}, () => this.emit('finish'); works around it. |
@jamesholcomb thanks for the good reproduction 👍 |
Here's a workaround I'm using that does not require changing the lib: setTimeout(() => logger.end(), 1000) |
Is there an internal path forward on this? The workaround is not effective for task oriented processes that perform heavy logging then exit...it's impossible to know how long to delay. |
@jamesholcomb I think to address this what we would need to do would be to add a feature to Another workaround you might be able to use Node.js', |
How is this not a bug? The suggested way of flushing logs doesn't work in this basic reproducible environment This also happens to us occasionally, and we couldn't use Is there any possible solution for this? In v2 I could have flushed the logs without ending by using the callback arg in |
@jamesholcomb and @RLRabinowitz , do you think that fix provided by @chrismaree helps? |
Hey @losalex. As far as I understand, that's just the workaround to add |
We've ended up using a transport that had its own implementation of "wait for logs to flush" - https://github.com/lazywithclass/winston-cloudwatch with the Then, we just explicitly call this method when closing out the process |
@RLRabinowitz , sorry for late reply and thanks for shared workaround! |
After looking for this issue more, unfortunately I do not have a great solution for this problem without making some redesign - the removed callback support in |
Hey @losalex, gotta say that I'm not sure what other option would be available, other than bringing back callback functionality. We've already solved our issue internally with this workaround mentioned above, which is specific to the transports we use My main issue with this personally right now is that the "breaking changes" part of the changelog is misleading. The suggested way of migrating to 3.0 is wrong, it should either mention |
Thanks @RLRabinowitz for your response - I agree that the migration was not properly addressed. I am not sure what exactly happened (this migration predates me), but I guess that |
I understand that updating the README can help explain the context of the bug, but this needs to remain open so that a proper fix can be implemented. @bcoe suggested a path forward by tracking pending requests. |
Thanks for your comment @jamesholcomb - sorry, this issue was closed automatically by README change and no time was given to provide more comments. Perhaps I should explain more on a reason why I think there is no good solution might be here. Tracking pending requests could address the issue only partially - correct me if I wrong, but some of the data still could be buffered on a transport level. Also worth mentioning that I do not see a |
@losalex it seems like winston implements its logger as a It looks like the |
Environment details
@google-cloud/logging-winston
version: 3.0.6winston
3.2.1Steps to reproduce
Winston 3 now has a mechanism to wait for logs to flush described here: https://github.com/winstonjs/winston/blob/master/UPGRADE-3.0.md#winstonlogger
Since upgrading, I am unable to get the logs to flush before the process exits (via signal or normal termination).
Output error:
If I comment out the LoggingWinston transport setup, there is no error.
The text was updated successfully, but these errors were encountered: