Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gw): panic in handler_car.go #255

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions gateway/handler_car.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ func (i *handler) serveCAR(ctx context.Context, w http.ResponseWriter, r *http.R

_, copyErr := io.Copy(w, carFile)
carErr := <-errCh
if copyErr != nil || carErr != nil {
streamErr := multierr.Combine(carErr, copyErr)
if streamErr != nil {
// We return error as a trailer, however it is not something browsers can access
// (https://github.com/mdn/browser-compat-data/issues/14703)
// Due to this, we suggest client always verify that
// the received CAR stream response is matching requested DAG selector
w.Header().Set("X-Stream-Error", multierr.Combine(err, copyErr).Error())
w.Header().Set("X-Stream-Error", streamErr.Error())
return false
}

Expand Down