-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add handleRejections support #1462
Add handleRejections support #1462
Conversation
Thanks for this PR! Looks very nice! 😎 Folks have wanted this feature for a while. Re: tests, do you have e.g. a plain node.js file you or I can run to see if this works or not (i.e., outside of mocha or any other test frameworks)? I can take a look at the mocha stuff but it would be helpful to have some starting point for testing. Thanks again for your work on this! |
@DABH The below code will throw an unhandled rejection:
Under Node 8.11. I tried figuring out a way to test it but didn't have much success. |
Updated package-lock.json so there are no conflicts. Since the changes are approved, will this be merged soon? Not sure if anyone has looked into the testing. cc: @DABH |
Hi, is this fix safe? Our team is relying on it but was waiting for it to be officially merged into the project. |
Please merge! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 87 in lib/winston/rejection-handler.js
has a typo, unhandledJejection
Corrected, @awill1988 |
Howdy folks – life happened for a little while over here. @DABH and I have monthly syncs to review & triage large features like this, but I missed the last two 😳 As such we'll be doing some overdue (my fault) maintenance in the next week or so. Keep an eye out for a minor release. In principle |
@indexzero - may I just say thank you for being awesome. No need to apologize for that. |
Since tests look like they're passing now, I think that this should be able to drop in the next release. I looked through the code again and it still looks good. The one thing I'm concerned about is exit behavior -- with ExceptionHandler, there are several open issues right now about e.g. exceptions not being logged before the program exits (I have a PR to fix that though). But I wonder if there's a similar issue with rejections since code is mostly same as ExceptionHandler. In any case we could probably look into that after merging this, especially if people are already using this feature branch and finding it useful/working. |
FWIW I would love to see this merged / released as well, and I'd be happy to help out with any outstanding issues that give you pause @DABH :-) |
Reviewed this with @DABH today and we are 👍 – David is going to apply his fix from #1355 to this post-merge and then it will go out in |
* Add handleRejections suppot * Correct typo
Adds missing typescript typings: #1842 |
Adds #921
However, needs some work because, although this seems like it should work, I don't think the tests are right since no log is created in fixtures.
It almost feels like it's silently not working, but I can't figure out how to get past mocha's "make sure your promise resolves" in order to test that it rejects. (and handled by winston)
Hope this is a good starting point for someone. Leaving the WIP tag to indicate it shouldn't be merged without double-checking the testing.