go: runtime: wasm: all goroutines asleep and no JavaScript callback pending - deadlock

I’ve seen a few trybot flakes on wasm like:

https://storage.googleapis.com/go-build-log/fd762fcb/js-wasm_280bcf2c.log (from wasm-unrelated https://go-review.googlesource.com/c/go/+/123779)

ok  	math/bits	1.768s
ok  	math/cmplx	1.762s
ok  	math/rand	4.233s
ok  	mime	1.705s
ok  	mime/multipart	6.236s
ok  	mime/quotedprintable	3.097s
ok  	net	2.596s
error: all goroutines asleep and no JavaScript callback pending - deadlock!
FAIL	net/http	15.608s
2018/07/13 22:17:40 Failed: exit status 1

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Oh 🤦‍♂️ For someone who is looking for a quick answer, just wrap your request in a go-routine because

A blocking callback should therefore explicitly start a new goroutine.

example := func(i []js.Value) {
	go func() {
		fmt.Println(http.Get("http://localhost:9276/"))
	}()
}
js.Global().Set("example", js.NewCallback(example))
select {}