Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix lint errors
  • Loading branch information
Matt Loring committed May 24, 2017
commit 13313bbe3a4e6bd26bec760b66ce510e37557009
6 changes: 3 additions & 3 deletions src/async-wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Author

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.

obj, v8::PropertyAttribute::DontEnum).FromJust();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want the user to be able to alter these? In src/async-wrap.cc I used

  v8::PropertyAttribute ReadOnlyDontDelete =
      static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete);

Though I probably should have added DontEnum to that list.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this for now.

Expand Down
5 changes: 3 additions & 2 deletions test/parallel/test-async-wrap-getasyncid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Copy link
Copy Markdown
Member

@AndreasMadsen AndreasMadsen May 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to expose the PromiseWrap on the new Promise object. PromiseWrap just has to be the resource object in the init hook, and the PromiseWrap object has to point to the new Promise object.

We don't expose *Wrap objects to userland in any other way than through the async_hooks resource object.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. I don't see any reason for getAsyncId to be exposed on promises.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the comment to reflect this.

}

Expand Down