-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: wasm: all goroutines asleep and no JavaScript callback pending - deadlock #26382
Comments
Change https://golang.org/cl/123936 mentions this issue: |
When using callbacks, it is not necessarily a deadlock if there is no runnable goroutine, since a callback might still be pending. If there is no callback pending, Node.js simply exits with exit code zero, which is not desired if the Go program is still considered running. This is why an explicit check on exit is used to trigger the "deadlock" error. This CL makes it so this is Go's normal "deadlock" error, which includes the stack traces of all goroutines. Updates #26382 Change-Id: If88486684d0517a64f570009a5ea0ad082679a54 Reviewed-on: https://go-review.googlesource.com/123936 Run-TryBot: Richard Musiol <neelance@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@bradfitz Please post a link here if you see it happening again, so I can check the stack traces. |
I think I ran into the same issue with https://play.golang.org/p/Ymt6QgfYH93. Not sure if I'm underestimating the complexity of the fix. |
Change https://golang.org/cl/127515 mentions this issue: |
@xudongzheng Your issue is unrelated to the flake above. Please see https://tip.golang.org/pkg/syscall/js/#NewCallback on why it happens. |
I get this error when I'm doing a http request within a callback function. Apparently
|
@kaskavalci - You have successfully repeated the issue in #26382 (comment). See the comment above. |
Oh 🤦♂️
example := func(i []js.Value) {
go func() {
fmt.Println(http.Get("http://localhost:9276/"))
}()
}
js.Global().Set("example", js.NewCallback(example))
select {} |
@gopherbot please file this to be considered for backport to 1.11. |
Backport issue(s) opened: #27425 (for 1.11). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
@bradfitz Is there a way to search the trybot logs for this flake? |
According to the logs, the last time this happened was on 2018/07/19. I'd say we can close this. |
I'm getting a similar error after upgrading from Go 1.12 to 1.13:
even though there should be a callback ( |
@danaugrs Please open a new issue, we don't track closed issues, and that's a pretty generic error. |
@FiloSottile I figured it out, the problem was reading from the channel of a |
if use goroutine, how return value to frontend ? |
this still happens to me with package main
import (
"io/ioutil"
"log"
"net/http"
"syscall/js"
)
func add(this js.Value, args []js.Value) interface{} {
resp, err := http.Get("https://jsonplaceholder.typicode.com/posts")
if err != nil {
log.Fatalln(err)
}
//We Read the response body on the line below.
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
}
//Convert the body to type string
sb := string(body)
log.Printf(sb)
return nil
}
func main() {
c := make(chan struct{}, 0)
js.Global().Set("add", js.FuncOf(add))
<-c
} result: #26382 (comment) running this in a goroutine works: package main
import (
"io/ioutil"
"log"
"net/http"
"syscall/js"
)
func add(this js.Value, args []js.Value) interface{} {
go func() {
resp, err := http.Get("https://jsonplaceholder.typicode.com/posts")
if err != nil {
log.Fatalln(err)
}
//We Read the response body on the line below.
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
}
//Convert the body to type string
sb := string(body)
log.Printf(sb)
}()
return nil
}
func main() {
c := make(chan struct{}, 0)
js.Global().Set("add", js.FuncOf(add))
<-c
} |
@loeffel-io Your issue is unrelated to the flake above. Please see https://pkg.go.dev/syscall/js@master#FuncOf on why it happens. |
My fault - thanks! @neelance |
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)
The text was updated successfully, but these errors were encountered: