Skip to content
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

wasm: node.js wiki example fails; syntax error in wasm_exec.js reported #27972

Closed
dtenenba opened this issue Oct 2, 2018 · 4 comments
Closed
Labels
arch-wasm WebAssembly issues FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@dtenenba
Copy link

dtenenba commented Oct 2, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.11.1 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

$ go env | egrep "GOOS|GOARCH"
GOARCH="amd64"
GOOS="darwin"

macOS 10.14

What did you do?

I followed the wiki example.
I ran every step on that page, up to and including the first command in the
node.js section.

What did you expect to see?

I expected to see the output:

Hello, WebAssembly!

What did you see instead?

$ GOOS=js GOARCH=wasm go run -exec="$(go env GOROOT)/misc/wasm/go_js_wasm_exec" .
/usr/local/go/misc/wasm/wasm_exec.js:215
						));
						^
SyntaxError: Unexpected token )
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:528:28)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3
exit status 1

It's not clear that there really is a syntax error in wasm_exec.js. The linter eslint does not report any problems with that file.

@dmitshur dmitshur self-assigned this Oct 2, 2018
@dmitshur dmitshur added the arch-wasm WebAssembly issues label Oct 2, 2018
@dmitshur dmitshur changed the title WASM: node.js wiki example fails; syntax error in wasm_exec.js reported wasm: node.js wiki example fails; syntax error in wasm_exec.js reported Oct 2, 2018
@dmitshur dmitshur added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 2, 2018
@dmitshur
Copy link
Contributor

dmitshur commented Oct 2, 2018

I can't reproduce this with Go 1.11.1:

$ go version
go version go1.11.1 darwin/amd64
$ cat main.go 
package main

import "fmt"

func main() {
	fmt.Println("Hello, WebAssembly!")
}
$ go run .
Hello, WebAssembly!
$ GOOS=js GOARCH=wasm go run -exec="$(go env GOROOT)/misc/wasm/go_js_wasm_exec" .
Hello, WebAssembly!

What version of node are you using? I have:

$ node --version
v10.11.0

@dmitshur
Copy link
Contributor

dmitshur commented Oct 2, 2018

Also, can you run this command and make sure you get the same output?

$ shasum -a 256 /usr/local/go/misc/wasm/wasm_exec.js
46ea07e1b594c1d5b163d875c54fac43b5d878f109c4e9ed5801bce20355b3c2  /usr/local/go/misc/wasm/wasm_exec.js

@dtenenba
Copy link
Author

dtenenba commented Oct 2, 2018

The file had the same checksum. But I was running node 6.7.0. I upgraded to the same version as you and the example worked! For anyone coming across this, this is how I upgraded:

sudo npm install n -g
sudo n 10.6.0

That was just for comparison with @dmitshur 's environment. Then I went ahead and upgraded to the latest stable version and the example still worked:

sudo n stable

@dtenenba dtenenba closed this as completed Oct 2, 2018
@mattetti
Copy link
Contributor

I had the same issue because I was on an older version of node (v7.4.0), I don't know if it's possible, but it would be nice to detect the node version and let the user know if the version isn't supported.

@golang golang locked and limited conversation to collaborators Jan 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly issues FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants