This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree 2 files changed +4
-14
lines changed 2 files changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,8 @@ module.exports = (send, path) => {
129
129
return
130
130
}
131
131
132
+ response . on ( 'error' , ( err ) => retStream . emit ( 'error' , err ) )
133
+
132
134
response . on ( 'data' , ( d ) => {
133
135
if ( d . Bytes && options . progress ) {
134
136
options . progress ( d . Bytes )
Original file line number Diff line number Diff line change @@ -47,28 +47,16 @@ function onRes (buffer, cb) {
47
47
// Return a stream of JSON objects
48
48
if ( chunkedObjects && isJson ) {
49
49
const outputStream = pump ( res , ndjson . parse ( ) )
50
- // TODO: This needs reworking.
51
- // this is a chicken and egg problem -
52
- // 1) we can't get Trailer headers unless the response ends
53
- // 2) we can't propagate the error, because the response stream
54
- // is closed
55
- // (perhaps we can workaround this using pull-streams)
56
50
res . on ( 'end' , ( ) => {
57
51
let err = res . trailers [ 'x-stream-error' ]
58
52
if ( err ) {
59
53
// Not all errors are JSON
60
54
try {
61
55
err = JSON . parse ( err )
62
56
} catch ( e ) {
63
- err = {
64
- Code : 'n/a' ,
65
- Message : err
66
- }
57
+ err = { Message : err }
67
58
}
68
- const error = new Error ( `Server responded with 500` )
69
- error . code = err . Code
70
- error . message = err . Message
71
- outputStream . destroy ( error ) // error is not going to be propagated
59
+ outputStream . emit ( 'error' , new Error ( err . Message ) )
72
60
}
73
61
} )
74
62
return cb ( null , outputStream )
You can’t perform that action at this time.
0 commit comments