Repository navigation
Throw within queueMicrotask callbacks should not crash Node #38145
Description
Activity
- changed the title
[-]Throw in the queueMicrotask callbacks[/-][+]Throw within queueMicrotask callbacks should not crash Node[/+]on Apr 8, 2021 - addedprocessIssues and PRs related to the process subsystem.Issues and PRs related to the process subsystem.
on Apr 8, 2021 The exception is reported via the
uncaughtExceptionevent. If nothing handles that, the exception is fatal, like all other uncaught exceptions.@devsnek ah that make sense.
Out of line question: there isn't an equivalent API on the Web that can do what
process.on('uncaughtException', ..)on Node, right?@Huxpro: there isn't an equivalent API on the Web that can do what process.on('uncaughtException', ..) on Node, right?
If you mean to monitor those uncaught exceptions, try
window.addEventListener('error', ...)(andunhandledrejectionforunhandledRejectionin Node.js respectively).@devsnek although it's spec-conformant in that sense. Why wouldn't
queueMicrotaskbehave the same assetTimeout?I'm reopening because it seems worth fixing (if possible) in the REPL.
Reacted by Xuan Huang (黄玄)- addedreplIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
on Apr 11, 2021 I'm reopening because it seems worth fixing (if possible) in the REPL.
This actually works in the REPL of Node 12 and 14.4 but stopped working in Node 14.5. I think that the issue is that errors thrown in queueMicroTask don't get captured by the domain, and don't reach the domain error handler (in the repl). The behaviour change was probably caused by this change #33859
Reacted by Anna Henningsen@Linkgoron Does it still need fixing?
@EladKeyshawn yes, it does.
The question is how something like that might be solved. One way would be to use child processes to execute the code and to detect fatal exceptions leading to a new child process. However, that would only recover the REPL but all former input would be lost. Thus, we would have to print a clear warning about what happened. This is the best solution I can think of and it would also resolve multiple other reports.
- addedconfirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Nov 29, 2021 There's been no further discussion or activity on this in years. Is this still relevant? Still an issue? Is it something that just needs to be documented better?
Reacted by Dario Piotrowicz
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
If I understood the spec correct:
It should behave similarly as Timer tasks.
What do you see instead?
Node crashed
Additional information
I did some preliminary triages that hopefully helps a bit:
task_queues.jsinvokerunMicrotasknode_task_queue.ccwhich invokes V8'sPerformCheckpointunder the hood.PerformCheckpointinvoked V8'sRunMicrotasksto actually evaluate those JS callbacks.But since V8's
PerformCheckpointreturnsvoid. I'm not sure how can Node be aware of any exceptions threw during the evaluation of those JS callbacks. Chromium seems to handle this fine but I haven't got time looking at its source.