Always include the X-Stream-Error trailer (even without errors)
This is to potentially address things like this: https://github.com/nodejs/undici/issues/432#issuecomment-1047931107
This commit is contained in:
parent
a2b89f9b3b
commit
787aea5f31
|
@ -644,6 +644,10 @@ func (api *API) StreamResponse(w http.ResponseWriter, next StreamIterator, errCh
|
|||
|
||||
if err != nil {
|
||||
w.Header().Set("X-Stream-Error", err.Error())
|
||||
} else {
|
||||
// Due to some Javascript-browser-land stuff, we set the header
|
||||
// even when there is no error.
|
||||
w.Header().Set("X-Stream-Error", "")
|
||||
}
|
||||
// check for function errors
|
||||
for funcErr := range errCh {
|
||||
|
|
|
@ -156,7 +156,9 @@ func (c *defaultClient) handleStreamResponse(resp *http.Response, handler respon
|
|||
trailerErrs := resp.Trailer.Values("X-Stream-Error")
|
||||
var err error
|
||||
for _, trailerErr := range trailerErrs {
|
||||
err = multierr.Append(err, errors.New(trailerErr))
|
||||
if trailerErr != "" {
|
||||
err = multierr.Append(err, errors.New(trailerErr))
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user