-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
async_wrap,src: promise hook integration #13000
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
Changes from 1 commit
ef35de1
563c1b0
4aaadc0
70f9675
0afbcfc
833ad39
5717d75
34ee31f
e0c194b
e1c11e7
d47e97a
012171a
4e38bda
13313bb
9b9c310
81ff7f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -291,9 +291,9 @@ static void PromiseHook(PromiseHookType type, Local<Promise> promise, | |
| env->promise_wrap(), | ||
| v8::External::New(env->isolate(), wrap), | ||
| v8::PropertyAttribute::DontEnum).FromJust(); | ||
| // The async tag will be destroyed at the same time as the promise as the only | ||
| // reference to it is held by the promise. This allows the promise wrap instance | ||
| // to be notified when the promise is destroyed. | ||
| // The async tag will be destroyed at the same time as the promise as the | ||
| // only reference to it is held by the promise. This allows the promise | ||
| // wrap instance to be notified when the promise is destroyed. | ||
| promise->DefineOwnProperty(context, | ||
| env->promise_async_tag(), | ||
| obj, v8::PropertyAttribute::DontEnum).FromJust(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want the user to be able to alter these? In v8::PropertyAttribute ReadOnlyDontDelete =
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);Though I probably should have added
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This property will be going away as soon as we move to an internal property on promises (blocked on #13175). I can modify this but I intend to get the promise internal property refactoring in before 8.0.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added this for now. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,8 +67,9 @@ function testInitialized(req, ctor_name) { | |
|
|
||
|
|
||
| { | ||
| // We don't want to expose getAsyncId for promises but we need to construct one | ||
| // so that the cooresponding provider type is removed from the providers list. | ||
| // We don't want to expose getAsyncId for promises but we need to construct | ||
| // one so that the cooresponding provider type is removed from the | ||
| // providers list. | ||
| new Promise((res) => res(5)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need to expose the We don't expose
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So does this mean that we do not need to expose a "getAsyncId" operation for promises (adding it will have performance implications so it would be great if it isn't needed)?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. I don't see any reason for
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated the comment to reflect this. |
||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
promise_async_tag()used for, preventing garbage collection? If so I think a comment should be added.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reference to it is held by the promise. We use its lifespan to approximate when the promise was garbage collected. I've added a comment describing this.