analysis/appengine: use a 60s timeout when fetching query results
Change-Id: Id4d36e9da9839d85d37947b09303ec57121b6fb1
Reviewed-on: https://go-review.googlesource.com/35873
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/analysis/appengine/app.go b/analysis/appengine/app.go
index 2b92c2c..1eba780 100644
--- a/analysis/appengine/app.go
+++ b/analysis/appengine/app.go
@@ -9,7 +9,9 @@
"log"
"net/http"
"os"
+ "time"
+ "golang.org/x/net/context"
"golang.org/x/perf/analysis/app"
"golang.org/x/perf/storage"
"google.golang.org/appengine"
@@ -31,6 +33,11 @@
// write to.
func appHandler(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
+ // urlfetch defaults to 5s timeout if the context has no timeout.
+ // The underlying request has a 60 second timeout, so we might as well propagate that here.
+ // (Why doesn't appengine do that for us?)
+ ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
+ defer cancel()
app := &app.App{
StorageClient: &storage.Client{
BaseURL: mustGetenv("STORAGE_URL_BASE"),