proposal: context: context.Expired #73533
Labels
LibraryProposal
Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool
Proposal
Milestone
Proposal Details
Proposal Details
Proposed addition:
Motivation
Currently, many codebases should check whether the error is context.Canceled or context.DeadlineExceeded like this.
As the above case, it's right if developer want to detect any context cancellation, but this handling is redundant.
This syntax search shows:
Of course it's fine that's only redundant, unfortunately, some bugs can be happened since the returning error is different by Cancel and Timeout.
These are example that happens bugs.
trinodb/trino-go-client#140
argoproj/argo-cd#22824
These cases tried to consider cancellation correctly, but the difference between the explicit cancellation and timeouted cancellation couldn't be considered. To reduce these subtle incorrect handling, I propose above new API.
Of course, we can use Canceled and DeadlineExceeded separately to distinguish these error.
The text was updated successfully, but these errors were encountered: