Skip to content

Commit

Permalink
Merge pull request #85 from netlify/mrdg/handle-client-cancel
Browse files Browse the repository at this point in the history
Don't treat client cancellation as error
  • Loading branch information
mrdg committed Aug 8, 2023
2 parents d57925e + d1354a0 commit 65848d7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/errors.go
Expand Up @@ -2,6 +2,7 @@ package api

import (
"context"
"errors"
"fmt"
"net/http"
"os"
Expand Down Expand Up @@ -167,6 +168,10 @@ func handleError(err error, w http.ResponseWriter, r *http.Request) {
}

func proxyErrorHandler(w http.ResponseWriter, r *http.Request, err error) {
if err := r.Context().Err(); errors.Is(err, context.Canceled) {
w.WriteHeader(499)
return
}
log := getLogEntry(r)
log.WithError(err).Warn("Failed proxying request")
w.WriteHeader(http.StatusBadGateway)
Expand Down

0 comments on commit 65848d7

Please sign in to comment.