Skip to content
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

current uid is a stack #10

Closed
AndreasMadsen opened this issue Aug 25, 2016 · 5 comments
Closed

current uid is a stack #10

AndreasMadsen opened this issue Aug 25, 2016 · 5 comments
Labels

Comments

@AndreasMadsen
Copy link
Owner

MakeCallback is sometimes called synchronously, thus uid can have multiple values in the same synchronous context.

@Fishrock123
Copy link
Collaborator

Fishrock123 commented Sep 18, 2016

I think this should be fixed transitively via #16?

@AndreasMadsen
Copy link
Owner Author

I think they are quite unrelated. The fix is just:

const currState = [root];

function asyncInit(uid, handle, provider, parentUid) {
  // get parent state
  const state = (parentUid === null ? currState[currState.length - 1] : stateMap.get(parentUid));

  // add new state node
  stateMap.set(uid, state.add(handle));
}

function asyncBefore(uid) {
  const state = stateMap.get(uid);

  state.before();
  currState.push(state);
}

function asyncAfter(uid) {
  const state = stateMap.get(uid);

  state.after();
  currState.pop();
}

but I haven't been able to create a test script for it.

@Fishrock123
Copy link
Collaborator

Sorry, wrong issue. I think this should be fixed by the actual async_hooks impl? aka nodejs/node#8531

@AndreasMadsen
Copy link
Owner Author

AndreasMadsen commented Sep 18, 2016

Yes, it provided an API for getting the contextual parent.

@AndreasMadsen
Copy link
Owner Author

Turns out that the basic http test does cover this after all. Fixed in a88b889

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants