From e1e888ea1afdd866fc0f4527bdc53a84cb5768eb Mon Sep 17 00:00:00 2001 From: achingbrain Date: Tue, 7 Apr 2020 18:04:40 +0100 Subject: [PATCH 1/3] fix: destroy the stream reguardless --- src/http.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/http.js b/src/http.js index 2106335..56c011e 100644 --- a/src/http.js +++ b/src/http.js @@ -269,9 +269,7 @@ const streamToAsyncIterator = function (source) { const wrapper = { next: iter.next.bind(iter), return: () => { - if (source.writableEnded) { - source.destroy() - } + source.destroy() return iter.return() }, From 9d7ba3ed85b926cf077f02da525067413ae30ef8 Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 8 Apr 2020 12:38:46 +0100 Subject: [PATCH 2/3] chore: detect PassThrough stream with source.hasOwnProperty --- src/http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http.js b/src/http.js index 56c011e..7d47b3e 100644 --- a/src/http.js +++ b/src/http.js @@ -263,7 +263,7 @@ const ndjson = async function * (source) { const streamToAsyncIterator = function (source) { if (isAsyncIterator(source)) { // Workaround for https://github.com/node-fetch/node-fetch/issues/766 - if (source.writable && source.readable) { + if (source.hasOwnProperty('readable') && source.hasOwnProperty('writable')) { const iter = source[Symbol.asyncIterator]() const wrapper = { From d2f8d1d24cb36a21dff2221a4716865fcb41e18c Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 8 Apr 2020 13:34:59 +0100 Subject: [PATCH 3/3] chore: linting --- src/http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http.js b/src/http.js index 7d47b3e..7ec3b0f 100644 --- a/src/http.js +++ b/src/http.js @@ -263,7 +263,7 @@ const ndjson = async function * (source) { const streamToAsyncIterator = function (source) { if (isAsyncIterator(source)) { // Workaround for https://github.com/node-fetch/node-fetch/issues/766 - if (source.hasOwnProperty('readable') && source.hasOwnProperty('writable')) { + if (Object.prototype.hasOwnProperty.call(source, 'readable') && Object.prototype.hasOwnProperty.call(source, 'writable')) { const iter = source[Symbol.asyncIterator]() const wrapper = {