You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While serving HTTP request we have req.Context() that can be propagated down the pipe. This context can be canceled either by standard library - by http.Server itself in case of communication issues or by http.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:
This would be very useful. Nowadays, when I see that a request failed due to context canceled, I have no idea happened. It could be a timeout on a SQL query, some internal request, etc. And if the context was canceled, because the client closed the connection (which happens in (*connReader).backgrounRead() -> cr.handleReadError(err), as far as I'm able to tell), I'd like to be able to distinguish it and not log it as an error.
changed the title
proposal: net/http: Add context cancelation reason for server handlers
proposal: net/http: add context cancelation reason for server handlers
Jan 13, 2024