Given the example from https://nodejs.org/api/stream.html#stream_piping_to_writable_streams_from_async_iterators.
There is a problem where this can cause an unhandled exception if the writable emits an 'error' before the first chunk arrives from the iterator, e.g. if writable is a fs stream and it fails while opening the file.
constwritable=fs.createWriteStream('./file');forawait(constchunkofiterator){// Handle backpressure on write().if(!writable.write(chunk))awaitonce(writable,'drain');}writable.end();// Ensure completion without errors.awaitfinished(writable);
Given the example from https://nodejs.org/api/stream.html#stream_piping_to_writable_streams_from_async_iterators.
There is a problem where this can cause an unhandled exception if the
writableemits an'error'before the first chunk arrives from theiterator, e.g. ifwritableis afsstream and it fails while opening the file.