-
Notifications
You must be signed in to change notification settings - Fork 30k
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
promise: Add --throw-unhandled-rejection and --trace-unhandled-rejection #6355
promise: Add --throw-unhandled-rejection and --trace-unhandled-rejection #6355
Conversation
if (process.argv[2] === 'child') { | ||
const rejectPromise = () => { | ||
return new Promise((resolve, reject) => { | ||
setTimeout(reject(new Error('Reject Promise')), 100); |
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.
If you want to have the reject()
call delayed, you need to wrap it in a closure, i.e. setTimeout(() => reject(new Error('Reject Promise')), 100);
. Right now, the whole child
block is equivalent to Promise.reject(new Error('Reject Promise'))
.
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.
Thanks, I fixed it.
/cc @benjamingr |
…ion option --throw-unhandled-rejection option can throw Exception when no unhandledRejection listener --trace-unhandled-rejection option can output error on stderr when no unhandledRejection listener
bedb1aa
to
580ca38
Compare
I'm -1 on this change. We should not be adding flags for these things - the reason we have an "abort on uncaught exceptions" flag is because of core dumps. What we should be doing is defaulting to logging these errors rather than silently swallowing them - like browsers and other languages do. |
Don't throws have the same stacktrace? The behavior should really just throw by default as I have mentioned before. Ideally after checking in a more deterministic way. (e.g. GC) In lieu of that, logging could be fine. I won't be able to finish the GC idea for v6, that's for sure. |
@Fishrock123 great, can we maybe bring logging by default to a vote and can I count on your vote with the caveat that we can might instead throw on GC collection? |
@benjamingr @Fishrock123 If no one has a strong objection to logging messages, I will close this PR and send next PR. |
I'm getting the GC and processes end handlers working. Standby.. |
Updated #5292 ... still working on one last point. PTAL. |
#6375 should probably supersede this. |
7da4fd4
to
c7066fb
Compare
Refs: nodejs#5292 Refs: nodejs/promises#26 Refs: nodejs#6355 PR-URL: nodejs#6375
Refs: nodejs#5292 Refs: nodejs/promises#26 Refs: nodejs#6355 PR-URL: nodejs#6375
Refs: nodejs#12010 Refs: nodejs#5292 Refs: nodejs/promises#26 Refs: nodejs#6355 PR-URL: nodejs#6375
src: use std::map for the promise reject map Refs: nodejs#5292 Refs: nodejs/promises#26 Refs: nodejs#6355 Refs: nodejs#6375
Checklist
Affected core subsystem(s)
promise
Description of change
We are writing a lots of Promise modules and test these modules in our development environment. When
process.on('unhandledRejection')
error is occurred, default node behavior does not send any message, no warnings, no exceptions. So we have to prepare the following code and add tests.This is not so easy for Promise / Node beginner. So I would like to propose the following 2 options.
--throw-unhandled-rejection
option will throw Exception when no unhandledRejection listener--trace-unhandled-rejection
option will output stderr when no unhandledRejection listenerI know the default unhandledRejection behavior is discussing here
nodejs/promises#26
But I would like to add these options to help our developments.