Skip to content

Commit cb46bc5

Browse files
committed
Rethrow async cb error as JS exception
After nodejs/node#12838 is merged, the exception will be properly reported.
1 parent 4236269 commit cb46bc5

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

napi-inl.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,16 +2684,7 @@ inline void AsyncWorker::OnWorkComplete(
26842684
self->OnError(Error::New(self->_env, self->_error));
26852685
}
26862686
} catch (const Error& e) {
2687-
// A JS or N-API exception was thrown, and propagated as a C++ exception.
2688-
// But throwing a JS exception here would have no effect because there
2689-
// is no JS on the callstack.
2690-
2691-
// TODO: Print the exception details and abort, just like Node.js normally
2692-
// does for unhandled exceptions. But there is no N-API function for that.
2693-
// For now just assert, so at least the exception message is discoverable
2694-
// in a debug build.
2695-
const char* message = e.what();
2696-
assert(false);
2687+
e.ThrowAsJavaScriptException();
26972688
}
26982689
}
26992690
delete self;

0 commit comments

Comments
 (0)