Explorar o código

Respond with 499 is a client closed the connection

DarthSim %!s(int64=5) %!d(string=hai) anos
pai
achega
e31950e1ef
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      timer.go

+ 4 - 0
timer.go

@@ -21,6 +21,10 @@ func checkTimeout(ctx context.Context) {
 	case <-ctx.Done():
 		d := getTimerSince(ctx)
 
+		if ctx.Err() != context.DeadlineExceeded {
+			panic(newError(499, fmt.Sprintf("Request was cancelled after %v", d), "Cancelled"))
+		}
+
 		if newRelicEnabled {
 			sendTimeoutToNewRelic(ctx, d)
 		}