diff --git a/index.js b/index.js index 67705d8..6008dcb 100644 --- a/index.js +++ b/index.js @@ -53,7 +53,9 @@ function requestAsEventEmitter(opts) { return; } - ee.emit('response', typeof unzipResponse === 'function' ? unzipResponse(res) : res); + setImmediate(function () { + ee.emit('response', typeof unzipResponse === 'function' ? unzipResponse(res) : res); + }); }).once('error', function (err) { if (retryCount < opts.retries) { setTimeout(get, backoff(retryCount++), opts); diff --git a/test/redirects.js b/test/redirects.js index 529997c..d468d49 100644 --- a/test/redirects.js +++ b/test/redirects.js @@ -92,7 +92,7 @@ test('redirects - redirect only GET and HEAD requests', t => { }); }); -test.after('redirect - cleanup', t => { +test.after('redirects - cleanup', t => { s.close(); t.end(); });