Skip to content

syscall/js: "goroutines are asleep" error only in Node.js #32764

@agnivade

Description

@agnivade

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

$ go version
go version go1.12.4 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

package main

import (
	"fmt"
	"syscall/js"
)

func main() {
	var cb js.Func
	cb = js.FuncOf(func(this js.Value, args []js.Value) interface{} {
		fmt.Println("cb called")
		return nil
	})
	js.Global().Set("callme", cb)
	done := make(chan struct{})
	fmt.Println("waiting for callback")
	<-done
}

I ran this in both browser and Node.js.

What did you expect to see?

I expect in both cases, for the program to wait indefinitely.

What did you see instead?

In works fine in browser:

$#go_js_wasm_exec is set to wasmbrowsertest
$GOOS=js GOARCH=wasm go run foo.go 
waiting for callback
^Csignal: interrupt

But fails in Node.js

$PATH=/usr/local/go/misc/wasm:$PATH GOOS=js GOARCH=wasm go run foo.go 
waiting for callback
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]:
main.main()
	/home/agniva/play/go/src/foo.go:24 +0xb
exit status 2

Is this expected ?

My node version is 10.2.1

/cc @neelance

I haven't tried with 1.11 because the function semantics have changed since.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.arch-wasmWebAssembly issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions