appengine icon indicating copy to clipboard operation
appengine copied to clipboard

datastore: Specific timeout errors

Open fredr opened this issue 7 years ago • 2 comments

In both Java and Python it is possible to handle datastore timeout errors in code, according to this text: https://cloud.google.com/appengine/articles/handling_datastore_errors

In Go however, a error from the internal packages are returned (Call error 11: Deadline exceeded (timeout) ) where there is no mention of datastore.

It would be nice if there was a specific error, like there is with datastore's concurrent transaction error ErrConcurrentTransaction.

fredr avatar Nov 08 '17 09:11 fredr

Apparently you can check if an error is a timeout error: https://cloud.google.com/appengine/docs/standard/go/reference#IsTimeoutError

import "google.golang.org/appengine"
...
appengine.IsTimeoutError(err)

Unfortunately that doesn't appear to work for me. Maybe you've got more luck?

ldej avatar Dec 21 '17 12:12 ldej

@ldej appengine.IsTimeoutError only works for some timeouts. If you check the code, it checks for context.DeadlineExeeded-error and errors that implement IsTimeout() bool. So it misses i.e url.Error that instead implement Timeout() bool

So we implemeted our own IsTimeoutError(error) bool that checks for all of those

fredr avatar Dec 25 '17 23:12 fredr