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
OS & version: Linux pc 5.3.18-1-MANJARO Stream support #1 SMP PREEMPT Wed Dec 18 18:34:35 UTC 2019 x86_64 GNU/Linux
got.stream() stream emits finish before error in case of ECONNREFUSED. The finish event should be used to signal that all data has been written/sent once stream.end() has been called (https://nodejs.org/api/stream.html#stream_event_finish).
Actual behavior
stream.pipeline() promise is resolved.
Expected behavior
stream.pipeline() should be rejected with ECONNREFUSED;
Code to reproduce
This code
constfs=require('fs');constutil=require('util');conststream=require('stream');constpipeline=util.promisify(stream.pipeline);constgot=require('got');asyncfunctionrun(){awaitpipeline(// Read small filefs.createReadStream('/proc/version'),// Generates ECONNREFUSEDgot.stream.put('http://localhost:7777'))}run().then(()=>{console.log('done');}).catch((err)=>{console.log('err',err);})
Prints:
done
It seems that this is because stream.pipeline() considers the data handled if the finish event is received. To isolate the issue I wrote another small test:
aalexgabi
changed the title
got.stream() swallows errors when used with pipeline
got.stream() swallows errors when used to upload small files with pipeline
Jan 17, 2020
aalexgabi
changed the title
got.stream() swallows errors when used to upload small files with pipeline
got.stream() swallows errors when used to upload small files with stream.pipeline()
Jan 17, 2020
Describe the bug
got.stream()
stream emitsfinish
beforeerror
in case ofECONNREFUSED
. Thefinish
event should be used to signal that all data has been written/sent once stream.end() has been called (https://nodejs.org/api/stream.html#stream_event_finish).Actual behavior
stream.pipeline()
promise is resolved.Expected behavior
stream.pipeline()
should be rejected withECONNREFUSED
;Code to reproduce
This code
Prints:
It seems that this is because
stream.pipeline()
considers the data handled if the finish event is received. To isolate the issue I wrote another small test:Which prints:
Note that if I read
/dev/urandom
(a bigger file) instead of/proc/version
the stream.pipeline() promise is rejected.Checklist
The text was updated successfully, but these errors were encountered: