You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems v11 streams are a little bit broken when used with async iteration:
'use strict';constgot=require('got');(async()=>{consttimeout=setTimeout(()=>{},10000);try{conststreamResponse=got.stream('https://sindresorhus.com');forawait(constchunkofstreamResponse){console.log('chunk from streamResponse');}console.log('end');}finally{clearInterval(timeout);}})();
This doesn't output anything. Note there is no error, where in a situation of a non-implemented async iterator should throw a TypeError saying "streamResponse is not async iterable" (you can add streamResponse[Symbol.asyncIterator] = undefined; to show that).
Now, a functional version (I used node's streams Readable.wrap for simplicity but implementing the right Symbol.asyncIterator is surely better):
'use strict';constgot=require('got');const{Readable}=require('stream');(async()=>{consttimeout=setTimeout(()=>{},10000);try{constgotStreamResponse=got.stream('https://sindresorhus.com');conststreamResponse=newReadable().wrap(gotStreamResponse);forawait(constchunkofstreamResponse){console.log('chunk from streamResponse');}console.log('end');}finally{clearInterval(timeout);}})();
This one outputs results:
chunk from streamResponse
chunk from streamResponse
end
It seems v11 streams are a little bit broken when used with async iteration:
This doesn't output anything. Note there is no error, where in a situation of a non-implemented async iterator should throw a TypeError saying "streamResponse is not async iterable" (you can add
streamResponse[Symbol.asyncIterator] = undefined;
to show that).Now, a functional version (I used node's streams Readable.wrap for simplicity but implementing the right Symbol.asyncIterator is surely better):
This one outputs results:
Link it to #1154
The text was updated successfully, but these errors were encountered: