-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: net/http: add context cancelation reason for server handlers #64465
Comments
You can make use of the Cause apis to do that, |
The idea of the proposal is to add cause for cases when context is canceled within standard library itself. And yes it can be accomplished with |
This would be very useful. Nowadays, when I see that a request failed due to |
cc @neild |
I'd like to work on this. I haven't contributed before, but I think this could be a good first issue and I'm running into it. My proposal would be to change
Feedback is welcome. In the meantime, I'll be following the contribution guide. |
When we cancel a HTTP server handler context, set an appropriate cancel cause. This makes investigation of context cancellation errors easier. Fixes golang#64465
When we cancel a HTTP server handler context, set an appropriate cancel cause. This makes investigation of context cancellation errors easier. Fixes golang#64465
When we cancel a HTTP server handler context, set an appropriate cancel cause. This makes investigation of context cancellation errors easier. Fixes golang#64465
Change https://go.dev/cl/636235 mentions this issue: |
Mainly, I believe this proposal requires consensus about the following three
|
Proposal Details
While serving HTTP request we have
req.Context()
that can be propagated down the pipe. This context can be canceled either by standard library - byhttp.Server
itself in case of communication issues or byhttp.TimeoutHandler
. But also it can be canceled by user code.It would be nice to have ability to clarify the reason why context was canceled (in case it was canceled by standard library). Logged reason will make you 100% sure and should make investigation of such context cancellation errors easier.
I'm ready to make a PR in case this proposal is considered useful.
The text was updated successfully, but these errors were encountered: