diff --git a/src/http.js b/src/http.js index 2106335..7ec3b0f 100644 --- a/src/http.js +++ b/src/http.js @@ -263,15 +263,13 @@ 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 (Object.prototype.hasOwnProperty.call(source, 'readable') && Object.prototype.hasOwnProperty.call(source, 'writable')) { const iter = source[Symbol.asyncIterator]() const wrapper = { next: iter.next.bind(iter), return: () => { - if (source.writableEnded) { - source.destroy() - } + source.destroy() return iter.return() },