Closed jpodwys closed 8 years ago
I've made the same PR to the original compression
as well. Doug and I are having some good discussion about it. Perhaps wait on this PR until Doug and I decide how best to accomplish my goal. Thanks for the awesome work!
I want to be able to use
compression
to enable GZIP on streamed responses that flush multiple chunks to the browser whenever the implementer wants. (This is especially useful when implementing a BigPipe algorithm such as with myexpress-stream
library.) As a result, I need a sure way of flushing only after a chunk of output has been zipped.Currently, the following code encounters a race condition because
res.write
is not blocking. As a result, it's possible thatres.flush
will execute beforeres.write
completes.I've confirmed the above by ensuring this works as expected:
What I'd prefer to do, and what this PR enables, is the following: