瀏覽代碼

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)
 		}