Skip to content

chore: avoid logging http.ErrAbortHandler panics #6686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2023

Conversation

deansheather
Copy link
Member

httputil.ReverseProxy will panic with http.ErrAbortHandler when it can't copy the response properly (source). This could be because the client closed their browser window or killed the CLI etc.

This isn't a traditional panic caused by a developer error, and is unavoidable in production so we should avoid logging them.

The err == http.ErrAbortHandler check is also how the recover handler built into the stdlib operates (source).

chi's recovery middleware also functions the same way (source).

@deansheather deansheather enabled auto-merge (squash) March 21, 2023 03:49
@deansheather deansheather merged commit 8aae0b6 into main Mar 21, 2023
@deansheather deansheather deleted the dean/dont-log-abort-panics branch March 21, 2023 03:51
@github-actions github-actions bot locked and limited conversation to collaborators Mar 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants