mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-10-04 18:33:36 +02:00
Better timeout/cancel detection
This commit is contained in:
@@ -32,13 +32,16 @@ func CheckTimeout(ctx context.Context) {
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
d := ctxTime(ctx)
|
d := ctxTime(ctx)
|
||||||
|
|
||||||
if ctx.Err() != context.DeadlineExceeded {
|
err := ctx.Err()
|
||||||
|
switch err {
|
||||||
|
case context.Canceled:
|
||||||
panic(ierrors.New(499, fmt.Sprintf("Request was cancelled after %v", d), "Cancelled"))
|
panic(ierrors.New(499, fmt.Sprintf("Request was cancelled after %v", d), "Cancelled"))
|
||||||
}
|
case context.DeadlineExceeded:
|
||||||
|
|
||||||
metrics.SendTimeout(ctx, d)
|
metrics.SendTimeout(ctx, d)
|
||||||
|
|
||||||
panic(ierrors.New(503, fmt.Sprintf("Timeout after %v", d), "Timeout"))
|
panic(ierrors.New(503, fmt.Sprintf("Timeout after %v", d), "Timeout"))
|
||||||
|
default:
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
// Go ahead
|
// Go ahead
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user