Переглянути джерело

Respond with 499 is a client closed the connection

DarthSim 5 роки тому
батько
коміт
e31950e1ef
1 змінених файлів з 4 додано та 0 видалено
  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)
 		}