GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — process: use owner symbol to access more public APIs in _getActive* by addaleax · Pull Request #22002 · nodejs/node

Conversation

@addaleax

@addaleax addaleax commented Jul 27, 2018

Copy link
Copy Markdown
Member

Use a standardized owner_symbol key to access the corresponding “public” JS wrapper object for a native handle. Currently, this is only implemented for the objects that already had some sort of owner keys, but this should be a first step towards making this a more common pattern.

/cc @nodejs/diagnostics

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot

nodejs-github-bot commented Jul 27, 2018

Copy link
Copy Markdown
Collaborator

@addaleax build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/367/pipeline

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added the lib / src Issues and PRs involving general changes in the lib/ or src/ directories. label Jul 27, 2018
@addaleax addaleax added the process Issues and PRs related to the process subsystem. label Jul 27, 2018
jasnell
jasnell approved these changes Jul 27, 2018
View reviewed changes

@jasnell jasnell left a comment

Copy link
Copy Markdown
Member

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.

Nice.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cjihrig
cjihrig approved these changes Jul 27, 2018
View reviewed changes
maclover7
maclover7 approved these changes Jul 27, 2018
View reviewed changes
mcollina
mcollina approved these changes Jul 27, 2018
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

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.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
joyeecheung
joyeecheung approved these changes Jul 27, 2018
View reviewed changes
@maclover7

maclover7 commented Jul 27, 2018

Copy link
Copy Markdown
Contributor

I forget if there's a deprecation process for to remove strings from Environment, but looks like the last two use cases for env->owner_string() are removed here, so that could possibly be ✂️as well

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

devsnek
devsnek approved these changes Jul 27, 2018
View reviewed changes
@addaleax

addaleax commented Jul 27, 2018

Copy link
Copy Markdown
Member Author

@maclover7 env.h has NODE_WANT_INTERNALS guards, it’s private API and we don’t need to worry about that. I’ve removed them, thanks for catching that 🙂

maclover7 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

refack
refack reviewed Jul 27, 2018
View reviewed changes
Comment thread src/async_wrap.cc Outdated

@refack refack Jul 27, 2018

Copy link
Copy Markdown
Contributor

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 will happen if we have a pathological case of cyclic ownership?

a[owner_symbol] = b;
b[owner_symbol] = a;

Is there a cycle safe STL algorithm for such a recursive walk?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@addaleax addaleax Jul 27, 2018

Copy link
Copy Markdown
Member Author

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.

It’s going to run into an infinite loop, yes.

Is there a cycle safe STL algorithm for such a recursive walk?

No, but you could implement something like a set of seen objects. The performance impact would be very noticeable, though.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@refack refack Jul 27, 2018

Copy link
Copy Markdown
Contributor

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.

You could just limit the loop to an arbitrary number of iterations and crash. IMHO better than a infinite busy loop, but I have no strong feelings about this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

AndreasMadsen, devsnek, and himself65 reacted with thumbs up emoji
All reactions
  • 👍 3 reactions
@AndreasMadsen

AndreasMadsen commented Jul 27, 2018

Copy link
Copy Markdown
Member

This is awesome, does this mean we can also start exposing the owner resource as the async_hooks resource?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jul 27, 2018

Copy link
Copy Markdown
Member

This is awesome, does this mean we can also start exposing the owner resource as the async_hooks resource?

Certainly safer to do so. I still think it may be worthwhile exploring a minimal shared interface for such resources, but I'd be much happier exposing the owner than the handle.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Jul 27, 2018

Copy link
Copy Markdown
Member Author

@AndreasMadsen @jasnell I’d really like that (and the fact that GetOwner() methods are being introduced here are a step towards it), but it’s not happening in this PR at least because the native handles are constructed before the property can be set on them. I think it’s doable but not trivial to make that work.

AndreasMadsen reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JungMinu
JungMinu approved these changes Jul 28, 2018
View reviewed changes
TimothyGu
TimothyGu approved these changes Jul 28, 2018
View reviewed changes
@AndreasMadsen AndreasMadsen mentioned this pull request Jul 28, 2018
async_hooks: add getActiveResources (prototype) #21453
Closed
2 of 4 tasks
@BridgeAR

BridgeAR commented Jul 29, 2018

Copy link
Copy Markdown
Member

This needs a rebase.

addaleax reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax added 4 commits July 29, 2018 16:27
@addaleax
lib,src: standardize owner_symbol for handles
df90330
Instead of somtimes using an `owner` string to link from a
native handle object to the corresponding JS object, standardize
on a single symbol that fulfills this role.
@addaleax
process: use owner_symbol for _getActive*
df15145
This makes it easier to provide public APIs in the return types
of `process._getActiveHandles()` and `process._getActiveRequests()`.
@addaleax
fixup! process: use owner_symbol for _getActive*
4c477b9
@addaleax
fixup! lib,src: standardize owner_symbol for handles
8d547e5
@addaleax
addaleax force-pushed the async-owner branch from 6167376 to 8d547e5 Compare July 29, 2018 14:47
@addaleax

addaleax commented Jul 29, 2018

Copy link
Copy Markdown
Member Author

CI: https://ci.nodejs.org/job/node-test-pull-request/16059/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Jul 29, 2018
@Fishrock123

Fishrock123 commented Jul 30, 2018

Copy link
Copy Markdown
Contributor

This seems like a good idea.

Two questions:

  1. Are we sure we've covered backwards compat enough for now?
  2. Should we deprecate the .owner get/setter, or is that waiting for some other time?
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Jul 30, 2018

Copy link
Copy Markdown
Contributor

Hmm, on second thought... since this symbol isn't exposed, doesn't this make it difficult to get the owner from a handle as available from an async hook callback?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AndreasMadsen

AndreasMadsen commented Jul 30, 2018

Copy link
Copy Markdown
Member

@Fishrock123 Just want to point out that the resource in async_hooks is not a public API. Especially since running console.log(resource) can crash the application ;)

The API for accessing this information is currently not considered public, but using the Embedder API, users can provide and document their own resource objects.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Jul 30, 2018

Copy link
Copy Markdown
Contributor

Just want to point out that the resource in async_hooks is not a public API.

That doesn't make it not a thing to think about.

Especially since running console.log(resource) can crash the application ;)

I can think of lots of ways to crash a node application. Yes, accessing a resource during the init callback specifically is sometimes one of them.

That doesn't mean that people aren't using it, or that it is useful, or that there aren't use-cases we should still keep in mind even for "unofficial" things.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Jul 30, 2018

Copy link
Copy Markdown
Member Author
  1. Are we sure we've covered backwards compat enough for now?

I’m not sure what more to provide than getter/setter pairs for the deprecated properties.

The more breaking-change-y patches will be when we add this symbol to other types of handles.

  1. Should we deprecate the .owner get/setter, or is that waiting for some other time?

No hurry, I’d say.

Hmm, on second thought... since this symbol isn't exposed, doesn't this make it difficult to get the owner from a handle as available from an async hook callback?

@Fishrock123 Would that concern be alleviated once we move async_hooks to also use this symbol for resource objects?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax

addaleax commented Aug 1, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

New CI: https://ci.nodejs.org/job/node-test-pull-request/16121/

Edit: Resume CI: https://ci.nodejs.org/job/node-test-pull-request/16127/

Edit: Resume Resume CI: https://ci.nodejs.org/job/node-test-pull-request/16147/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ofrobots
ofrobots approved these changes Aug 1, 2018
View reviewed changes
@addaleax

addaleax commented Aug 5, 2018

Copy link
Copy Markdown
Member Author

Landed in af7164e, 5be9b1d

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@addaleax addaleax closed this Aug 5, 2018
@addaleax
addaleax deleted the async-owner branch August 5, 2018 12:00
addaleax added a commit that referenced this pull request Aug 5, 2018
@addaleax
lib,src: standardize owner_symbol for handles
af7164e
Instead of somtimes using an `owner` string to link from a
native handle object to the corresponding JS object, standardize
on a single symbol that fulfills this role.

PR-URL: #22002
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
addaleax added a commit that referenced this pull request Aug 5, 2018
@addaleax
process: use owner_symbol for _getActive*
5be9b1d
This makes it easier to provide public APIs in the return types
of `process._getActiveHandles()` and `process._getActiveRequests()`.

PR-URL: #22002
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
@targos targos added backport-requested-v10.x and removed author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Aug 6, 2018
@targos

targos commented Aug 6, 2018

Copy link
Copy Markdown
Member

Should this be backported to v10.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

Backport should be relatively easy. There is one more instance of owner_string in src/timer_wrap.cc.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos

targos commented Aug 19, 2018

Copy link
Copy Markdown
Member

Ping @addaleax

addaleax reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax added a commit to addaleax/node that referenced this pull request Aug 24, 2018
@addaleax
lib,src: standardize owner_symbol for handles
9e80cf1
Instead of somtimes using an `owner` string to link from a
native handle object to the corresponding JS object, standardize
on a single symbol that fulfills this role.

PR-URL: nodejs#22002
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
addaleax added a commit to addaleax/node that referenced this pull request Aug 24, 2018
@addaleax
process: use owner_symbol for _getActive*
ec8d38e
This makes it easier to provide public APIs in the return types
of `process._getActiveHandles()` and `process._getActiveRequests()`.

PR-URL: nodejs#22002
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Minwoo Jung <[email protected]>
Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
Reviewed-By: Ali Ijaz Sheikh <[email protected]>
@addaleax addaleax mentioned this pull request Aug 24, 2018
[v10.x] backport owner_symbol for process._getActive* #22507
Closed
addaleax added a commit that referenced this pull request Aug 28, 2018
@addaleax
lib,src: standardize owner_symbol for handles
c6a45f4
Instead of somtimes using an `owner` string to link from a
native handle object to the corresponding JS object, standardize
on a single symbol that fulfills this role.

PR-URL: #22002
Backport-PR-URL: #22507
Reviewed-By: Michaël Zasso <[email protected]>
addaleax added a commit that referenced this pull request Aug 28, 2018
@addaleax
process: use owner_symbol for _getActive*
97d7b5c
This makes it easier to provide public APIs in the return types
of `process._getActiveHandles()` and `process._getActiveRequests()`.

PR-URL: #22002
Backport-PR-URL: #22507
Reviewed-By: Michaël Zasso <[email protected]>
@targos targos added backported-to-v10.x and removed backport-requested-v10.x labels Aug 28, 2018
targos pushed a commit that referenced this pull request Sep 3, 2018
@addaleax @targos
lib,src: standardize owner_symbol for handles
46fbc23
Instead of somtimes using an `owner` string to link from a
native handle object to the corresponding JS object, standardize
on a single symbol that fulfills this role.

PR-URL: #22002
Backport-PR-URL: #22507
Reviewed-By: Michaël Zasso <[email protected]>
targos pushed a commit that referenced this pull request Sep 3, 2018
@addaleax @targos
process: use owner_symbol for _getActive*
5af6a89
This makes it easier to provide public APIs in the return types
of `process._getActiveHandles()` and `process._getActiveRequests()`.

PR-URL: #22002
Backport-PR-URL: #22507
Reviewed-By: Michaël Zasso <[email protected]>
@targos targos mentioned this pull request Sep 5, 2018
Release proposal: v10.10.0 #22716
Merged
targos pushed a commit that referenced this pull request Sep 6, 2018
@addaleax @targos
lib,src: standardize owner_symbol for handles
cae21ea
Instead of somtimes using an `owner` string to link from a
native handle object to the corresponding JS object, standardize
on a single symbol that fulfills this role.

PR-URL: #22002
Backport-PR-URL: #22507
Reviewed-By: Michaël Zasso <[email protected]>
targos pushed a commit that referenced this pull request Sep 6, 2018
@addaleax @targos
process: use owner_symbol for _getActive*
778ddc7
This makes it easier to provide public APIs in the return types
of `process._getActiveHandles()` and `process._getActiveRequests()`.

PR-URL: #22002
Backport-PR-URL: #22507
Reviewed-By: Michaël Zasso <[email protected]>
This was referenced Sep 6, 2018
2018-09-06 Version 10.10.0 (Current) @targos beevelop/docker-android-nodejs#236
Closed
2018-09-06 Version 10.10.0 (Current) @targos beevelop/docker-nodejs#221
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@mcollina mcollina mcollina approved these changes
@jasnell jasnell jasnell approved these changes
@cjihrig cjihrig cjihrig approved these changes
@joyeecheung joyeecheung joyeecheung approved these changes
@JungMinu JungMinu JungMinu approved these changes
+5 more reviewers
@refack refack refack left review comments
@ofrobots ofrobots ofrobots approved these changes
@TimothyGu TimothyGu TimothyGu approved these changes
@maclover7 maclover7 maclover7 approved these changes
@devsnek devsnek devsnek approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

lib / src Issues and PRs involving general changes in the lib/ or src/ directories. process Issues and PRs related to the process subsystem.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

16 participants

@addaleax @nodejs-github-bot @maclover7 @AndreasMadsen @jasnell @BridgeAR @Fishrock123 @targos @mcollina @ofrobots @refack @TimothyGu @cjihrig @joyeecheung @JungMinu @devsnek
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.