Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If they were synchronous and if they did take 5 seconds then yes, for that instance of the server, requests would be blocked. That's why it's critical that blocking calls (network, db, file system etc...) calls are async. The event loop has to keep looping or the whole server blocks.</p> <p><a href="http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/" rel="nofollow noreferrer">http://blog.mixu.net/2011/02/01/understanding-the-node-js-event-loop/</a></p> <p>A key line from that write up is:</p> <blockquote> <p>…however, everything runs in parallel except your code</p> </blockquote> <p>That means expensive I/O should be async but your code can block. but, it's typically expensive I/O that we're worried about blocking on the server.</p> <p>'Your code' is typically just handling callbacks from the long running I/O calls, updating your state and then firing off another call. But that's the beauty of it - when you're updating your state, it's on the main event loop so there's no need for multi-threaded access to 'your' state and code. No locking, no deadlocks etc... but all the benefits of async and parallel I/O which is the expensive part.</p> <p>The other key point (which 5 seconds of non-IO work would fall into) is:</p> <blockquote> <p>Other than I/O calls, Node.js expects that all requests return quickly; e.g. CPU-intensive work should be split off to another process with which you can interact as with events, or by using an abstraction like WebWorkers.</p> </blockquote> <p>Also, do expect 'auth' and 'POST' | 'PUT' to ever happen in the same request? If so, you may have an issue. getAuth looks to be async but then you immediately go to the req.method check. At that point, getAuth will still be working. If you want POST and PUT authenticated then that block of async methods may need to be wrapped with the getAuth async method.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload