Skip to content

cmd/trace: http /trace endpoint broken javascript #37987

@tatatodd

Description

@tatatodd

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

$ go version
go version go1.14 darwin/amd64

Does this issue reproduce with the latest release?

go.1.14 is the latest release. It also reproduces on go1.13.8

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/toddwang/Library/Caches/go-build"
GOENV="/Users/toddwang/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/toddwang/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="***REDACTED***/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rw/lyr53c8115bf5y6q_4f0_yyh0000gn/T/go-build853332319=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

  1. Create a trace.out file.
  2. Run go tool trace
$ go tool trace /tmp/trace.out
2020/03/21 12:34:08 Parsing trace...
2020/03/21 12:34:09 Splitting trace...
2020/03/21 12:34:10 Opening browser. Trace viewer is listening on http://127.0.0.1:53686
  1. Visit http://127.0.0.1:53686 in Chrome Version 80.0.3987.149 (Official Build) (64-bit)
  2. Click on View trace, which takes me to http://127.0.0.1:53686/trace. The page is empty.
  3. Open Chrome javascript console (cmd-opt-j on Mac).
  4. Reload http://127.0.0.1:53686/trace and see the broken javascript:
Uncaught ReferenceError: tr is not defined
    at onResult (trace:59)
    at trace:43
  1. Click through to see the JS that caused the error:
58  function onResult(result) {
59    model = new tr.Model();  ## tr is not defined here
60    var opts = new tr.importer.ImportOptions();
61    opts.shiftWorldToZero = false;
62    var i = new tr.importer.Import(model, opts);
63    var p = i.importTracesWithProgressDialog([result]);
64    p.then(onModelLoaded, onImportFail);
65  }
  1. Give up and file a bug, because I'm lousy at JS.

What did you expect to see?

I expect to see a non-empty trace in my browser. This is my first time using go tool trace so I don't know what it's supposed to show me. Note that the /trace endpoint is also used when you click on a specific goroutine number in the /goroutines page, and is similarly broken.

What did you see instead?

An empty trace in my browser, and the above broken javascript in the console.
AFAICT the other links on the local http server seem to work fine; only /trace seems to be broken.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions