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 @@ -123,6 +123,8 @@ module.exports = (send, path) => {
123
123
return retStream . push ( null ) // early
124
124
}
125
125
126
+ response . on ( 'error' , ( err ) => retStream . emit ( 'error' , err ) )
127
+
126
128
if ( ! isStream ( response ) ) {
127
129
retStream . push ( response )
128
130
retStream . push ( null )
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