-
this is happening and is legal: then I need to completely rethink my
understanding of data structure consistency in NodeJS.
…
-
it’s not actually happening and the call stack is a lie: but then I need
some other explanation for the data structure inconsistency that my
assertions are observing.
It’s a little bit of #1 and #3.
Your basic understanding of how asynchronous concurrency works in Node is
sound, but there’s one piece you seem to be missing: when you call an
asynchronous function (like request()) and pass it a callback, that
callback is going to be called on the other side of some kind of
asynchronous I/O operation (in request’s case, most likely reading the
response stream after making an external HTTP request). At some point, a
callback function (in this case, probably created by request) got handed
off to a lower-level operation (perhaps within fibers) that handed it over
to MakeCallback on the C++ side of node, which interfaces to the JS side
via _tickCallback when the runtime indicates that there are data available
to be read back from libuv.
My guess is that something about how node-fibers handles suspension and
resumption of its continuations / coroutines is interacting with the V8
stack in a funky way, but that the code is basically executing as expected.
I don’t use fibers, and maybe one of the people here who does can pitch in
here, but I think that’s not a deal breaker here – the only real
peculiarity they cause here is that because of how they staple call stacks
together, you’re seeing a stack trace that bridges an async call boundary.
Does that make sense?
F
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/CAHG3qKrbRygeONdyuV7Z0xWxmEmAQUvZahjJzYHS2OOKPZrrmQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.