From 2c2024be8b50392f8fbbf12899dea9ce8748d47b Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Tue, 4 Jul 2023 09:44:17 +0900 Subject: [PATCH] build: update distribution (#183) Co-authored-by: actions-bot --- dist/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 68c70ee..446c81b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3977,8 +3977,11 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) { if (headers['transfer-encoding'] === 'chunked' && !headers['content-length']) { response.once('close', function (hadError) { + // tests for socket presence, as in some situations the + // the 'socket' event is not triggered for the request + // (happens in deno), avoids `TypeError` // if a data listener is still present we didn't end cleanly - const hasDataListener = socket.listenerCount('data') > 0; + const hasDataListener = socket && socket.listenerCount('data') > 0; if (hasDataListener && !hadError) { const err = new Error('Premature close');