Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
doc: clarify
uncaughtException
origin
for ESM #41339doc: clarify
uncaughtException
origin
for ESM #41339Changes from 5 commits
df5db76
c3b2692
61eb69a
ffe2656
c8d2454
b589d69
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
can we just simplify this to
when in a Promise based async context
? Since purely with CJS and having no ESM this also happens in some cases.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.
Do you have a purely CJS example when this happen when
--unhandled-rejections
flag is NOT set tostrict
orthrow
?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.
@aduh95 I do not for that case, but it does happen outside of ES module static loading phase.
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.
Any chance we can list those edge cases as well? I don't think
when in a Promise based async context
does a great job at explaining when this will come up – my take away from #41328 is that it's not obvious to everyone that ESM loading isPromise
based, so imho it's worth explicitly list it here rather than expect readers to know what is aPromise
based context.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.
Didn’t the default for
--unhandled-rejections
change in 17? So it doesn’t need to be set anymore to get the error.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.
It changed in v15.0.0. But that's beside the point I think, this section of the docs is currently wrong, and if this PR doesn't do a good enough job to document when users should expect
unhandledRejection
rather thanuncaughtException
, I'm open to suggestions.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.
@aduh95 roughly anything that creates a Promise job causes that, so IDK where to start. If an uncaughtException would occur inside of an async function / inside of a Promise constructor/handler callbacks / inside ESM are all the real times that this happens. So uncaughtException isn't really about the source file / throwing at the top level, but it is about how it was invoked, always. Listing async functions and Promise methods might be enough?
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.
async functions, promise then/catch/finally, new Promise executor functions, and soon, Array.fromAsync
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.
@bmeck I think that is true when
--unhandled-rejections
is set tostrict
orthrow
(which is default), and we're in agreement on this part. I'll try to rephrase the sentence so this part is clearer.What is more tricky is that a rejection in the ES loader will always trigger an
'uncaughtException'
event withorigin
'unhandledRejection'
, even if--unhandled-rejections
is set tonone
(orwarn
orwarn-with-error-code
). At least to me, this part is surprising, and in contradiction with what the docs are currently saying, so I think it's worth documenting it. I believe that the ES module loader is the only piece of node that behaves like this, but if you know of another example, I can include it.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.
I can't think of another off the top of my head. I think we've done enough workshopping though that whatever is clarified seems good at this point.