http: unexpected EOF reading trailer not a temporary error?

670 views
Skip to first unread message

Jens-Uwe Mager

unread,
Apr 16, 2018, 6:09:09 PM4/16/18
to golang-nuts
I am checking net.error for the Temporary() condition, and in my very bad network I do see really a lot of errors. While doing a GET request I see that

http: unexpected EOF reading trailer

is not a temporary error, so my retry logic does not kick in. Is this a special case or just an oversight?

Ian Lance Taylor

unread,
Apr 16, 2018, 6:59:28 PM4/16/18
to Jens-Uwe Mager, golang-nuts
EOF means that the TCP connection has closed, so this error is not temporary.

Ian

Jens-Uwe Mager

unread,
Apr 17, 2018, 12:56:51 AM4/17/18
to golang-nuts
Looking further into this, I see this as a typical transient error in a bad network on downloading files. It may be different elsewhere, but I have to retry on that error as it appears. And I cannot change the network somewhere in the Guatemala outback.

Jakob Borg

unread,
Apr 17, 2018, 3:48:59 AM4/17/18
to Jens-Uwe Mager, golang-nuts
I think the definition of "temporary" is the issue here. Something like an underlying EAGAN is "temporary" - retrying the same operation that failed on the same socket again can succeed. A read error from a closed TCP connection is not temporary - reading again cannot possibly unclose the connection and suddenly succeed.

However, it not being a temporary error doesn’t mean that larger scale operation can never succeed - retrying by making another request can work.

In other words, for your HTTP purposes I don’t think the (*OpError).Temporary() is a valuable indicator. You’re probably better off considering known fatal HTTP errors as non-temporary (a 404 probably indicates the request won’t succeed in 500 ms either, unless you know otherwise) and other errors as transient and subject to a retry.

//jb

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages