Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.3k
async_wrap: add uid argument to all asyncWrap hooks#4600
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
Conversation
AndreasMadsen commented Jan 9, 2016
Added a commit b59518387ce3c151a52772bcd4c220b7400a98ab |
trevnorris commented Jan 11, 2016
CI: https://ci.nodejs.org/job/node-test-pull-request/1197/ LGTM. Great stuff. Thanks for taking care of this. |
AndreasMadsen commented Jan 18, 2016
Actually it is still necessary to mutate the handle object, because there is otherwise no way of relating the parent handle object to the corresponding user object. Should we replace the parent handle object with the parent uid? |
trevnorris commented Jan 18, 2016
@AndreasMadsen Can you expound on that? |
AndreasMadsen commented Jan 20, 2016
The long-stack-trace example explains it well: constuidSymbol=Symbol('uid');conststacks=newMap();letactiveHandleUid=-1;functioninit(uid,provider,parent){this[uidSymbol]=uid;constparentStack=stack.get(parent ? parent[uidSymbol] : activeHandleUid);constfullstack=combineStack(newError(),parentStack);stacks.set(uid,fullstack);}functionpre(uid){activeHandleUid=uid;}functionpost(uid){activeHandleUid=-1;}functiondestroy(uid){stacks.delete(uid);}By providing the parent uid such that the init hook becomes |
Qard commented Jan 20, 2016
Nice! 👍 for parentUid. |
trevnorris commented Jan 25, 2016
@AndreasMadsen That makes sense. Guess the initial reason I did this was so you could |
AndreasMadsen commented Jan 25, 2016
Yeah, that makes sense. But with the introduction of the PS (long): For some odd reason WeekMap does not work very well for storing custom user data (it might be a v8 bug, but I haven't investigated it that much). See: AndreasMadsen/trace#17 The graphs tells the story: |
trevnorris commented Jan 27, 2016
@AndreasMadsen Don't get me wrong. I didn't say it was a good solution. Only that it was a solution. Passing the id to all callbacks is preferable. |
AndreasMadsen commented Jan 29, 2016
Can we land this? PS: I had to rebase because of efd33a2 |
jasnell commented Feb 1, 2016
@trevnorris ... ping. Does this still look good to you? |
trevnorris commented Feb 1, 2016
@AndreasMadsen Sorry for the delay. It just occurred to me one reason I decided to pass the parent handle. Because if the user does something like: constasync_wrap=process.binding('async_wrap');async_wrap.setupHooks();require('net').createServer().listen();async_wrap.enable();Then there will be no way to reference the parent handle from the new connection simply by the uid. Any thoughts on this? I was considering if it were possible to |
trevnorris commented Feb 1, 2016
@AndreasMadsen Actually how about this. Move the parent object to the last argument for |
AndreasMadsen commented Feb 2, 2016
I think that if the user is interested in the handle object then the user should
The words move and init(uid,provider,parentUid,parentHandle);pre(uid);post(uid);destroy(uid);I think that's fine. |
trevnorris commented Feb 2, 2016
@AndreasMadsen My initial implementation of AsyncListener allowed to uniquely track all async paths. So it would've been possible to enable tracking of, say, a single TCP connection. For that to work it would have needed to know the parent of that connection when it was enabled. Would like to have that functionality again going forward, but may be out of scope. The signatures you outlined looks great. Thanks for your work on this. |
AndreasMadsen commented Feb 3, 2016
@trevnorris The general idea makes sense and I can see the relevance of the parent handle. However I'm not entirely convinced that it is necessary to provide the parent handle. That being said I would rather have that we provide too much information that too little. I've updated the last commit (1db5c06a34a58e6eb3bc2b8c77f3b2236f5e75dd) so it just adds the parent uid without removing the parent handle. |
trevnorris commented Feb 4, 2016
@AndreasMadsen Very excellent. CI: https://ci.nodejs.org/job/node-test-pull-request/1531/ CI is currently on lock down until security release is done. Will post results once it finishes. |
trevnorris commented Feb 4, 2016
Jenkins failed on the The failure on |
AndreasMadsen commented Feb 5, 2016
Hmm that is strange. I tried running the tests on Raspberry Pi 2 one running ArchLinux (1 error) another running Raspbian (0 errors). I doubt the ArchLinux error is related to this PR: So unfortunately I can't reproduce it. PS: When I try access https://ci.nodejs.org/job/node-test-pull-request/1531/ it says I don't have "read permissions". |
trevnorris commented Feb 5, 2016
@AndreasMadsen CI is currently on lock down b/c of security releases. Hence why I posted the entire error message instead of just the link. If you need any more info let me know. Running again to make sure this wasn't a fluke |
trevnorris commented Feb 6, 2016
The test is still failing. Not sure how this would be possible, since the other tests was succeeding. Will look into it. |
AndreasMadsen commented Feb 6, 2016
I'm curious, how are the tests executed? The Jenkins output has the format: while mine is so I'm guessing it isn't just |
Trott commented Feb 7, 2016
@AndreasMadsen I believe Jenkins runs |
AndreasMadsen commented Feb 9, 2016
@Trott thanks, unfortunately Is there a way to force node to use TCP wrap?
But I actually don't know when TCP is used :/ |
Trott commented Feb 10, 2016
@AndreasMadsen CI is unlocked now so you should be able to review the results and the full log to (hopefully) see exactly how to recreate the issues that are showing up there. One thing I notice is that You can review the tests that failed at https://ci.nodejs.org/job/node-test-binary-arm/972/ |
test/parallel/test-async-wrap-uid.js Outdated
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.
Better to have assert.strictEqual here.
By doing this users can use a Map object for storing information instead of modifying the handle object. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
All other hooks have uid as the first argument, this makes it concistent for all hooks. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
When the parent uid is required it is not necessary to store the uid in the parent handle object. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
By doing this users can use a Map object for storing information instead of modifying the handle object. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
All other hooks have uid as the first argument, this makes it concistent for all hooks. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
When the parent uid is required it is not necessary to store the uid in the parent handle object. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
By doing this users can use a Map object for storing information instead of modifying the handle object. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
All other hooks have uid as the first argument, this makes it concistent for all hooks. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
When the parent uid is required it is not necessary to store the uid in the parent handle object. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
By doing this users can use a Map object for storing information instead of modifying the handle object. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
All other hooks have uid as the first argument, this makes it concistent for all hooks. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
When the parent uid is required it is not necessary to store the uid in the parent handle object. Ref: #7048 PR-URL: #4600 Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>



By doing this, users can use a Map object for storing information instead of modifying the handle object.
@trevnorris mentioned this was an "API deficiency" https://github.com/nodejs/tracing-wg/pull/37/files#r48493114
Also, could we make
uidthe first argument in theinithook, such that it consistent for all hooks?