all: increase compile timeout to 10 seconds

This doubles our compile time to give us more room to figure out how to
optimize the module build path in the playground.

For golang/go#44822

Change-Id: I4f0153c9a835d18e0ab4e4af1b63bc52b4eebd52
Reviewed-on: https://go-review.googlesource.com/c/playground/+/302771
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/sandbox.go b/sandbox.go
index 83b5017..3d26dbb 100644
--- a/sandbox.go
+++ b/sandbox.go
@@ -44,8 +44,9 @@
 )
 
 const (
-	maxCompileTime = 5 * time.Second
-	maxRunTime     = 5 * time.Second
+	// Time for 'go build' to download 3rd-party modules and compile.
+	maxBuildTime = 10 * time.Second
+	maxRunTime   = 5 * time.Second
 
 	// progName is the implicit program name written to the temp
 	// dir and used in compiler and vet errors.
@@ -501,7 +502,7 @@
 	if err := cmd.Start(); err != nil {
 		return nil, fmt.Errorf("error starting go build: %v", err)
 	}
-	ctx, cancel := context.WithTimeout(ctx, maxCompileTime)
+	ctx, cancel := context.WithTimeout(ctx, maxBuildTime)
 	defer cancel()
 	if err := internal.WaitOrStop(ctx, cmd, os.Interrupt, 250*time.Millisecond); err != nil {
 		if errors.Is(err, context.DeadlineExceeded) {