Go: x/playground: show a meaningful error message for build timeouts

Created on 24 Mar 2020  路  19Comments  路  Source: golang/go

What version of Go are you using (go version)?

The version of Go in use by the play.golang.org.

Does this issue reproduce with the latest release?

N/A

What operating system and processor architecture are you using (go env)?

Go Playground.

What did you do?

Import a module that imports golang.org/x/crypto.

package main

import (
    "fmt"

    "github.com/stellar/go/txnbuild"
)

func main() {
    tx := txnbuild.Transaction{}
    err := tx.Build()
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Println(tx)
}
--go.mod--
module play.ground
require github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3

https://play.golang.org/p/SK8gXGPzUvf

What did you expect to see?

I expected to see the playground's Go build process find golang.org/x/crypto and continue building, or if there is a build failure, a more meaningful error message.

What did you see instead?

When finding golang.org/x/crypto the build fails. No meaningful error message beyond that is displayed. Timeout is not mentioned so I don't think the process is taking too long and being killed.

go: finding github.com/stellar/go latest
go: downloading github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
go: extracting github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
go: downloading github.com/pkg/errors v0.8.1
go: downloading golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708
go: downloading github.com/lib/pq v1.2.0
go: downloading github.com/stellar/go-xdr v0.0.0-20180917104419-0bc96f33a18e
go: extracting github.com/pkg/errors v0.8.1
go: extracting github.com/stellar/go-xdr v0.0.0-20180917104419-0bc96f33a18e
go: extracting github.com/lib/pq v1.2.0
go: extracting golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/lib/pq v1.2.0
go: finding github.com/stellar/go-xdr v0.0.0-20180917104419-0bc96f33a18e
go: finding golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708

Go build failed.
NeedsFix

Most helpful comment

This snippet (https://play.golang.org/p/jRB81AYhnq8) now fails correctly:

timeout running go build
go: downloading github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
go: downloading github.com/pkg/errors v0.8.1
go: downloading github.com/stellar/go-xdr v0.0.0-20180917104419-0bc96f33a18e
go: downloading github.com/lib/pq v1.2.0
go: downloading golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708

Go build failed.

All 19 comments

It doesn't look like finding x/crypto is the problem here. There is some other build error after that that isn't logged. See this example with a different output: https://play.golang.org/p/D1_5KTesTr0

@FiloSottile What output do you see? I see the same output when I run your link.

go: finding github.com/stellar/go latest
go: downloading github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
go: extracting github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
go: downloading golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708
go: downloading github.com/pkg/errors v0.8.1
go: downloading github.com/lib/pq v1.2.0
go: downloading github.com/stellar/go-xdr v0.0.0-20180917104419-0bc96f33a18e
go: extracting github.com/pkg/errors v0.8.1
go: extracting github.com/lib/pq v1.2.0
go: extracting github.com/stellar/go-xdr v0.0.0-20180917104419-0bc96f33a18e
go: extracting golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708
go: finding github.com/pkg/errors v0.8.1
go: finding github.com/lib/pq v1.2.0
go: finding github.com/stellar/go-xdr v0.0.0-20180917104419-0bc96f33a18e
go: finding golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708

Go build failed.

Ahh, I think we might be on to something. Check this out if I import the crypto package directly: https://play.golang.org/p/pcRtlFF7Ihs.

go: finding golang.org/x/crypto latest
go: downloading golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59
go: extracting golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59
build command-line-arguments: cannot load golang.org/x/crypto: module golang.org/x/crypto@latest found (v0.0.0-20200323165209-0ec3e9974c59), but does not contain package golang.org/x/crypto

Go build failed.

馃う鈥嶁檪 That was silly of me. There are no .go files in the root of the crypto project, so that 鈽濓笍 error is irrelevant.

I see this at https://play.golang.org/p/D1_5KTesTr0

go: finding github.com/stellar/go latest
go: downloading github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
go: extracting github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3

Maybe this is purely a timeout issue?

The --go.mod-- line is invalid: it is missing spaces around the -- tokens.

But we should be producing a better error message for that.

FWIW, here's what I get on the command line:

play.ground$ txtar -x > main.go <<EOF
package main

import (
        "fmt"

        "github.com/stellar/go/txnbuild"
)

func main() {
        tx := txnbuild.Transaction{}
        err := tx.Build()
        if err != nil {
                fmt.Println(err)
                return
        }
        fmt.Println(tx)
}
--go.mod--
module play.ground
require github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
EOF

play.ground$ go build .
go: finding module for package github.com/stellar/go/txnbuild
go: downloading github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
go: found github.com/stellar/go/txnbuild in github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
go: downloading github.com/pkg/errors v0.8.1
go: downloading github.com/lib/pq v1.2.0
go: downloading golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708
go: downloading github.com/stellar/go-xdr v0.0.0-20180917104419-0bc96f33a18e
# play.ground
./main.go:18:1: syntax error: non-declaration statement outside function body

play.ground$ cat main.go
package main

import (
        "fmt"

        "github.com/stellar/go/txnbuild"
)

func main() {
        tx := txnbuild.Transaction{}
        err := tx.Build()
        if err != nil {
                fmt.Println(err)
                return
        }
        fmt.Println(tx)
}
--go.mod--
module play.ground
require github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3

play.ground$

Hmm, but fixing that doesn't fix the Playground build. There is something else going on _too_.

https://play.golang.org/p/-YW3xkuXIm1 fails with the same inscrutable Go build failed. on the playground, but builds fine locally using go 1.14.1:

play.ground$ txtar -x >main.go <<EOF
> package main

import (
        "fmt"

        "github.com/stellar/go/txnbuild"
)

func main() {
        tx := txnbuild.Transaction{}
        err := tx.Build()
        if err != nil {
                fmt.Println(err)
                return
        }
        fmt.Println(tx)
}
-- go.mod --
module play.ground

go 1.13

require github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
EOF

play.ground$ go build .
go: downloading github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
go: downloading github.com/pkg/errors v0.8.1
go: downloading golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708
go: downloading github.com/stellar/go-xdr v0.0.0-20180917104419-0bc96f33a18e
go: downloading github.com/lib/pq v1.2.0

play.ground$

CC @andybons @dmitshur @toothrot @cagedmantis: do y'all maintain the Playground these days? (The entry for it at https://dev.golang.org/owners is blank; I know it used to be mainly @bradfitz.)

CC @ysmolsky who I think has done some work on it too.

@toothrot has offered to take a look.

The good news is this is reproducing when running the playground locally. I'm still looking into it.

Ok, after lots of cleanup and investigation, there's a bug in the playground. The build for this code is timing out, but the wrong context is being checked for the timeout error.

I'll have a patch ready for this soon, along with removing NaCL code as part of #25224

Change https://golang.org/cl/227352 mentions this issue: playground: move build and run into functions

Change https://golang.org/cl/227350 mentions this issue: playground: use the correct contexts for sandbox requests

Change https://golang.org/cl/228438 mentions this issue: playground: show a meaningful error on build timeout

This snippet (https://play.golang.org/p/jRB81AYhnq8) now fails correctly:

timeout running go build
go: downloading github.com/stellar/go v0.0.0-20200320201948-bab6abc8fbf3
go: downloading github.com/pkg/errors v0.8.1
go: downloading github.com/stellar/go-xdr v0.0.0-20180917104419-0bc96f33a18e
go: downloading github.com/lib/pq v1.2.0
go: downloading golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708

Go build failed.

Thanks again for the helpful issue report!

Was this page helpful?
0 / 5 - 0 ratings