-
Notifications
You must be signed in to change notification settings - Fork 30k
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
async-hooks: Is that possible to expose PromiseHooks resolve callback? #14038
Comments
Yes, it would be possible to expose Just mentioning one thing that was really confusing me: const p1 = new Promise(() => {}); // This will never be resolved
const p2 = new Promise((resolve) => setTimeout(resolve, 1000, p1)); // resolve p2 with p1 after 1s
|
@addaleax , thank you for reply and point out the case. const p2 = new Promise((resolve) => setTimeout(resolve, 1000, p1)); // resolve p2 with p1 after 1s yeah, in this case, if And in my understanding, this is the same with const p1 = {
then() {
// do something.
}
};
const p2 = new Promise((resolve) => setTimeout(resolve, 1000, p1)); // resolve p2 with p1 after 1s resolve a promise with |
It is, at least through C++ API and undocumented internal Node APIs ( |
@addaleax ,
yes, if possible , I think in my case |
@JiaLiPassion As I mentioned, it’s internal, and you should not rely on it; it can be removed or broken at any time. |
@addaleax , got it! I will try to find out is there any other way to know |
I am still working on porting
zone.js
withasync_hooks
. currently when I portingPromise
, I met a problem and I think I need theresolve
hook to be exposed.case1: promise's parent is an resolved promise.
In this case, current
async_hooks
API is ok, I can justschedule a microTask
inzone.js
in theinit
callback.case2: the promise's parent is an unresolved promise.
In this case, the
microTask
should not be scheduled ininit
, when thep1.then
is called, becausep1
is stillunresolved
, themicrotask
should be scheduled whenp1.resolve
iscalled, so I wonder is that possible to expose the
PromiseHook.resolve
callback throughasync_hooks
?Thank you very much!
The text was updated successfully, but these errors were encountered: