diff --git a/lib/zlib.js b/lib/zlib.js index 4a7c1ef153..3915e5ddab 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -474,7 +474,10 @@ function _close(engine, callback) { engine._closed = true; - engine._handle.close(); + // Caller may invoke .close after a zlib error (which will null _handle). + if (engine._handle) { + engine._handle.close(); + } } function emitCloseNT(self) {