Skip to content

Commit

Permalink
fix: Do not report context canceled errors to Sentry (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
phacops authored Dec 20, 2024
1 parent 7ae719e commit d4c23e3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/vroom/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,18 @@ func (env *environment) postProfile(w http.ResponseWriter, r *http.Request) {
err = storageutil.CompressedWrite(ctx, env.storage, p.StoragePath(), p)
s.Finish()
if err != nil {
if errors.Is(err, context.DeadlineExceeded) {
// This is a transient error, we'll retry
if errors.Is(err, context.DeadlineExceeded) || errors.Is(err, context.Canceled) {
// These are transient errors, we'll retry.
w.WriteHeader(http.StatusTooManyRequests)
} else {
if code := gcerrors.Code(err); code == gcerrors.FailedPrecondition {
// This indicates a duplicate, we won't retry.
w.WriteHeader(http.StatusPreconditionFailed)
} else {
if hub != nil {
hub.CaptureException(err)
}
// These errors won't be retried
// These errors won't be retried.
w.WriteHeader(http.StatusInternalServerError)
}
}
Expand Down

0 comments on commit d4c23e3

Please sign in to comment.