From 22f32d63832d533336c25557fefde5dee2943d4c Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Sat, 4 Jan 2014 03:03:11 -0800 Subject: zlib: emit after properly closed --- lib/zlib.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/zlib.js b/lib/zlib.js index 3341588e4..efa0f19b0 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -191,8 +191,9 @@ function zlibBuffer(engine, buffer, callback) { function onEnd() { var buf = Buffer.concat(buffers, nread); buffers = []; - callback(null, buf); - engine.close(); + engine.close(function() { + callback(null, buf); + }); } } @@ -421,10 +422,8 @@ Zlib.prototype.close = function(callback) { this._closed = true; - this._binding.close(); - var self = this; - process.nextTick(function() { + this._binding.close(function() { self.emit('close'); }); }; -- cgit v1.2.1