-
-
Notifications
You must be signed in to change notification settings - Fork 477
Phantom Promise
generated when returning a Promise
to C++ triggers the unhandledRejection
check
#1658
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
Comments
This is from instrumenting
|
If the const dll = require('./build/Debug/promise-from-cpp.node');
dll.start(() => {
const q = Promise.reject(1337);
q.mark = true;
return q;
}); then the second
|
There is code in webstreams that suspiciously look as a workaround for this issue: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is probably a V8 (or maybe Node.js) quirk, but since it is very
node-addon-api
-centric, I am posting it here.If a JS function called by C++ returns a rejected
Promise
, there will be another phantomPromise
- most probably originating in C++ code (see the traces below, it is rejected from the microtask queue) that will trigger theunhandledRejection
check. This goes back at least to Node.js 16.Ignoring the
unhandledRejection
check - by registering a callback or using the CLI option - solves the problem and everything works as expected.C++ code, slightly reworked
TypedThreasSafeFunction
example - but the problem is not specific to it:JS code:
The text was updated successfully, but these errors were encountered: