-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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_wrap: add uid argument to all asyncWrap hooks #4600
Conversation
Added a commit b59518387ce3c151a52772bcd4c220b7400a98ab |
CI: https://ci.nodejs.org/job/node-test-pull-request/1197/ LGTM. Great stuff. Thanks for taking care of this. |
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? |
@AndreasMadsen Can you expound on that? |
The long-stack-trace example explains it well: const uidSymbol = Symbol('uid');
const stacks = new Map();
let activeHandleUid = -1;
function init (uid, provider, parent) {
this[uidSymbol] = uid;
const parentStack = stack.get(parent ? parent[uidSymbol] : activeHandleUid);
const fullstack = combineStack(new Error(), parentStack);
stacks.set(uid, fullstack);
}
function pre (uid) {
activeHandleUid = uid;
}
function post (uid) {
activeHandleUid = -1;
}
function destroy (uid) {
stacks.delete(uid);
} By providing the parent uid such that the init hook becomes |
Nice! 👍 for parentUid. |
@AndreasMadsen That makes sense. Guess the initial reason I did this was so you could |
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: |
@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. |
Can we land this? PS: I had to rebase because of efd33a2 |
@trevnorris ... ping. Does this still look good to you? |
@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: const async_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 |
@AndreasMadsen Actually how about this. Move the parent object to the last argument for |
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. |
@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. |
@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. |
@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. |
Jenkins failed on the
The failure on |
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". |
@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 |
The test is still failing. Not sure how this would be possible, since the other tests was succeeding. Will look into it. |
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 |
@AndreasMadsen I believe Jenkins runs |
@Trott thanks, unfortunately Is there a way to force node to use TCP wrap?
But I actually don't know when TCP is used :/ |
@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/ |
async_wrap.disable(); | ||
|
||
process.once('exit', function() { | ||
assert.equal(storage.size, 2); |
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.
@trevnorris mentioned this was an "API deficiency" https://github.com/nodejs/tracing-wg/pull/37/files#r48493114
Also, could we make
uid
the first argument in theinit
hook, such that it consistent for all hooks?