diff --git a/lib/zlib.js b/lib/zlib.js index 79c78ea4a513..f114ed310630 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -467,7 +467,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) {