Skip to content

Instantly share code, notes, and snippets.

@mikedeboer
mikedeboer / resume_after_next.md
Created July 4, 2012 12:31
Why to call resume() after next()
View resume_after_next.md

When we write Connect middlewares that contain async operations, it is good practice to 'pause' the HTTP request with the help of the Connect utility function. When the async operation has finished, the HTTP request is resumed again. Let's have a look at the documentation for this utility:

Pause `data` and `end` events on the given `obj`.
Middleware performing async tasks _should_ utilize
this utility (or similar), to re-emit data once
the async operation has completed, otherwise these
events may be lost.