-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Unable to catch error thrown inside async function #936
Comments
I think it is probably related to the following code: Lines 394 to 400 in ffb41e6
From the doc, it seems that the handler could also fire another event saying that a handler is later added This is probably a related Node issue: nodejs/node#1912 |
Okay so I think this is indeed the problem. void ExitOnPromiseRejectCallback(
v8::PromiseRejectMessage promise_reject_message) {
auto* isolate = v8::Isolate::GetCurrent();
Deno* d = static_cast<Deno*>(isolate->GetData(0));
DCHECK_EQ(d->isolate, isolate);
v8::HandleScope handle_scope(d->isolate);
auto exception = promise_reject_message.GetValue();
auto context = d->context.Get(d->isolate);
+ printf("Promise reject try_catch caught, with %d\n", promise_reject_message.GetEvent());
- HandleException(context, exception);
} The following is printed when running the provided code:
From the doc, Probably this is one the reasons why Node choose not to exit on unhandled promise rejection? |
@ry I created an experimental branch to play around with this issue (I am not familiar with v8 so would definitely make some mistakes). Lines 1 to 8 in ffb41e6
With my attempted fix, the output changes from
to
which actually matches the output if running under Node. All other tests passes as usual though. Would like to know comments before submitting a possible PR. |
@kevinkassimo Yes, I think this is the reason why the test is not normal. |
- Fix promise reject issue (denoland#936) - Add --types command line flag. - Add metrics() - Add redirect follow feature denoland#934 - Fix clearTimer bug denoland#942 - Improve error printing denoland#935 - Expose I/O interfaces Closer, Seeker, ReaderCloser, WriteCloser, ReadSeeker, WriteSeeker, ReadWriteCloser, ReadWriteSeeker - Fix silent death on double await denoland#919 - Add Conn.closeRead() and Conn.closeWrite() denoland#903
- Fix promise reject issue (#936) - Add --types command line flag. - Add metrics() - Add redirect follow feature #934 - Fix clearTimer bug #942 - Improve error printing #935 - Expose I/O interfaces Closer, Seeker, ReaderCloser, WriteCloser, ReadSeeker, WriteSeeker, ReadWriteCloser, ReadWriteSeeker - Fix silent death on double await #919 - Add Conn.closeRead() and Conn.closeWrite() #903
If
fn
is synchronous instead, it works fine:I thought it might be related to #919, but this also happens with my own build of master after that was closed.
The text was updated successfully, but these errors were encountered: