Skip to content

net/http: WASM http.Get fails to read response and deadlocks when called in event listener #52737

Closed
@soypat

Description

@soypat

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

$ go version
go version go1.17.9 linux/amd64

Does this issue reproduce with the latest release?

It is my understanding an issue of this type would be fixed in both 1.17 and 1.18 latest versions, so yes?

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

GOOS=js GOARCH=wasm. For desktop application as follows:

go env Output

$ go env
GO111MODULE=""
GOARCH="386"
GOBIN="/home/pato/local/bin"
GOCACHE="/home/pato/.cache/go-build"
GOENV="/home/pato/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="386"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/pato/go/pkg/mod"
GONOPROXY="github.com/LIA-Aerospace"
GONOSUMDB="github.com/LIA-Aerospace"
GOOS="linux"
GOPATH="/home/pato/go"
GOPRIVATE="github.com/LIA-Aerospace"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_386"
GOVCS=""
GOVERSION="go1.17.9"
GCCGO="gccgo"
GO386="sse2"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/pato/Desktop/3dprint/wasm-listener-bug/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 -m32 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build434021559=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. Run following program https://github.com/soypat/wasm-listener-bug
git clone https://github.com/soypat/wasm-listener-bug wbug && cd wbug && go run .
  1. Head on over to http://[::]:8080/
  2. Click button
  3. See console log

What did you expect to see?

Error printout or success message. for http.Get attempt

What did you see instead?

Panic at https://github.com/soypat/wasm-listener-bug/blob/main/app/client.go#L60

fatal error: all goroutines are asleep - deadlock!
wasm_exec.js:51
wasm_exec.js:51 goroutine 1 [select (no cases)]:
wasm_exec.js:51 github.com/hexops/vecty.RenderBody({0xce1f0, 0x434050})
wasm_exec.js:51 /home/pato/go/pkg/mod/github.com/hexops/vecty@v0.6.0/dom.go:1195 +0x1e
wasm_exec.js:51 main.main()
wasm_exec.js:51 /home/pato/Desktop/3dprint/wasmbug/app/client.go:47 +0x32
wasm_exec.js:51
wasm_exec.js:51 goroutine 6 [select]:
wasm_exec.js:51 net/http.(*Transport).RoundTrip(0x353fa0, 0x42e000)
wasm_exec.js:51 /usr/local/go/src/net/http/roundtrip_js.go:170 +0x8d
wasm_exec.js:51 net/http.send(0x42e000, {0xc8c60, 0x353fa0}, {0x0, 0x0, 0x0})
wasm_exec.js:51 /usr/local/go/src/net/http/client.go:252 +0x8b
wasm_exec.js:51 net/http.(*Client).send(0x360d20, 0x42e000, {0x0, 0x0, 0x0})
wasm_exec.js:51 /usr/local/go/src/net/http/client.go:176 +0x11
wasm_exec.js:51 net/http.(*Client).do(0x360d20, 0x42e000)
wasm_exec.js:51 /usr/local/go/src/net/http/client.go:725 +0xb5
wasm_exec.js:51 net/http.(*Client).Do(...)
wasm_exec.js:51 /usr/local/go/src/net/http/client.go:593
wasm_exec.js:51 net/http.(*Client).Get(0x360d20, {0x76a54, 0x10})
wasm_exec.js:51 /usr/local/go/src/net/http/client.go:480 +0xe
wasm_exec.js:51 net/http.Get(...)
wasm_exec.js:51 /usr/local/go/src/net/http/client.go:449
wasm_exec.js:51 main.updateShape()
wasm_exec.js:51 /home/pato/Desktop/3dprint/wasmbug/app/client.go:65 +0x4
wasm_exec.js:51 main.addShapeListener.func1({0x260c0, 0x3832c8})
wasm_exec.js:51 /home/pato/Desktop/3dprint/wasmbug/app/client.go:60 +0x2
wasm_exec.js:51 vecty-templater-project/app/store.(*listenerRegistry).Fire(0x40c038, {0x260c0, 0x3832c8})
wasm_exec.js:51 /home/pato/Desktop/3dprint/wasmbug/app/store/listener.go:40 +0xa
wasm_exec.js:51 vecty-templater-project/app/store.OnAction({0x260c0, 0x3832c8})
wasm_exec.js:51 /home/pato/Desktop/3dprint/wasmbug/app/store/store.go:49 +0x21
wasm_exec.js:51 vecty-templater-project/app/store/actions.Dispatch({0x260c0, 0x3832c8})
wasm_exec.js:51 /home/pato/Desktop/3dprint/wasmbug/app/store/actions/dispatcher.go:14 +0x8
wasm_exec.js:51 vecty-templater-project/app/views.(*Body).newItem(...)
wasm_exec.js:51 /home/pato/Desktop/3dprint/wasmbug/app/views/body.go:46
wasm_exec.js:51 github.com/hexops/vecty.(*HTML).reconcileProperties.func1({0xd12d8, 0x42cd00}, {0x42cce0, 0x1, 0x1})
wasm_exec.js:51 /home/pato/go/pkg/mod/github.com/hexops/vecty@v0.6.0/dom.go:246 +0x1f
wasm_exec.js:51 github.com/hexops/vecty.funcOf.func1({{}, 0x7ff800010000002f, 0x49c4c0}, {0x42ccd0, 0x1, 0x1})
wasm_exec.js:51 /home/pato/go/pkg/mod/github.com/hexops/vecty@v0.6.0/dom_js.go:60 +0x10
wasm_exec.js:51 syscall/js.handleEvent()
wasm_exec.js:51 /usr/local/go/src/syscall/js/func.go:96 +0x27
wasm_exec.js:151 exit code: 2

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