We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dae0483 commit 1f7506dCopy full SHA for 1f7506d
src/http.js
@@ -262,6 +262,27 @@ const ndjson = async function * (source) {
262
263
const streamToAsyncIterator = function (source) {
264
if (isAsyncIterator(source)) {
265
+ // Workaround for https://github.com/node-fetch/node-fetch/issues/766
266
+ if (source.writable && source.readable) {
267
+ const iter = source[Symbol.asyncIterator]()
268
+
269
+ const wrapper = {
270
+ next: iter.next.bind(iter),
271
+ return: () => {
272
+ if (source.writableEnded) {
273
+ source.destroy()
274
+ }
275
276
+ return iter.return()
277
+ },
278
+ [Symbol.asyncIterator]: () => {
279
+ return wrapper
280
281
282
283
284
285
286
return source
287
}
288
0 commit comments