diff --git a/index.js b/index.js index c0e801e7..5d9b0df5 100644 --- a/index.js +++ b/index.js @@ -65,10 +65,15 @@ function compression (options) { var _on = res.on var _write = res.write + var flushCB = function flushCB () { + stream.flush() + } + // flush res.flush = function flush () { if (stream) { - stream.flush() + // call write and pass flushCB to force synchronous behavior + stream.write('', flushCB) } }