zeromq.node icon indicating copy to clipboard operation
zeromq.node copied to clipboard

Send from a request endpoint can trigger receive callbacks

Open jez9999 opened this issue 7 years ago • 3 comments

Following on from a question I filed on StackOverflow: http://stackoverflow.com/questions/39573399/why-are-my-request-and-response-messages-out-of-order

... from my reading of the code, a call to zmq.socket("req").send(...) can lead to a "message" callback being executed. In binding.cc, this seems to be because Socket::Sendv can call socket->NotifyReadReady().

Why does the code work this way? It seems to me to break the expected flow of Node.js, which is that events will only be triggered once the event loop finishes executing the current code. The way this is designed, the execution of the current code suddenly jumps to triggering callbacks and then returns to executing the current code. Why can't it just wait until the event loop is ready to check for responses? This behaviour should at least be separated out into a new send_and_check function or something.

jez9999 avatar Sep 20 '16 10:09 jez9999