Description
Extracting #32463 (comment) and #32463 (comment) from #32463, which was closed by removing ErrTemporary.
We've seen net.Error.Timeout()
become nearly useless because it got overloaded with too many different (and requiring different handling) timeout errors. Did a DNS request timeout, requiring a retry of the Dial? Did the keep-alive hit, breaking the connection? Did the deadline hit, meaning the Read can be retried after resetting it? Did a timeout happen that caused a fatal error that can't be retried? (More at #31449.)
I don't think there would be a semantic meaning to os.ErrTimeout either, except being something that's called a timeout. Adding a single ErrTimeout to the standard library would encourage lack of specificity, without having any upside, because errors.Is(err, ErrTimeout)
doesn't mean anything. Libraries and applications are better off using errors.New("this specific action timed out")
or defining their own timeout errors.
Instead, we should maybe have net.DeadlineExceeded
, which can always be handled by resetting a deadline.