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

syscall/js: wasm compiled tests not running in browser after async operations change #28068

agnivade opened this issue Oct 8, 2018 · 1 comment
arch-wasm WebAssembly issues FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.


Copy link

agnivade commented Oct 8, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version devel +165ebaf97b Sun Oct 7 02:36:02 2018 +0000 linux/amd64

Does this issue reproduce with the latest release?


What did you do?

I tried to run tests from standard library in the browser. See #26051 for more context. But after 0e4c013 was checked in, the tests seem to hang and not run.

Here is how to repro -

  1. Take the html and wasm_exec.js from GOROOT/misc/wasm/. Change the writeSync and openSync functions to write and open in global.fs in wasm_exec.js. (That is another thing we need to fix).

  2. Compile any test to a binary -
    /go/src/encoding$GOOS=js GOARCH=wasm gotip test -run=^TestDecode -o hex.wasm -c -v ./hex/

  3. Update your index.html to pass the args after getting the go object.
    go.argv = ['', '-test.v=true'];

  4. Try to run the test, by copying over the binary to your other folder and press the run button.

What did you expect to see?

I expect it to run all the tests

What did you see instead?

Only the first test was started, but then after that nothing else is running

Console was cleared
wasm_exec.js:45 === RUN   TestEncode

But if I revert this commit

commit 0e4c013b6743507ebce2c08991cf1e3ab49cf7ac
Author: Richard Musiol <>
Date:   Tue Sep 25 13:45:08 2018 +0200

    syscall: use asynchronous operations on js/wasm

and compile and run again, all tests run (also including the ones not in my pattern, which seems to be another issue). Make sure you have the writeSync and openSync functions again, not write and open. Or rather duplicate them so that it's easy to test.

Console was cleared
wasm_exec.js:54 === RUN   TestEncode
wasm_exec.js:54 --- PASS: TestEncode (0.00s)
wasm_exec.js:54 === RUN   TestDecode
wasm_exec.js:54 --- PASS: TestDecode (0.00s)
wasm_exec.js:54 === RUN   TestEncodeToString
wasm_exec.js:54 --- PASS: TestEncodeToString (0.00s)
wasm_exec.js:54 === RUN   TestDecodeString
wasm_exec.js:54 --- PASS: TestDecodeString (0.00s)
wasm_exec.js:54 === RUN   TestDecodeErr
wasm_exec.js:54 --- PASS: TestDecodeErr (0.00s)
wasm_exec.js:54 === RUN   TestDecodeStringErr
wasm_exec.js:54 --- PASS: TestDecodeStringErr (0.00s)
wasm_exec.js:54 === RUN   TestEncoderDecoder
wasm_exec.js:54 --- PASS: TestEncoderDecoder (0.01s)
wasm_exec.js:54 === RUN   TestDecoderErr
wasm_exec.js:54 --- PASS: TestDecoderErr (0.00s)
wasm_exec.js:54 === RUN   TestDumper
wasm_exec.js:54 --- PASS: TestDumper (0.00s)
wasm_exec.js:54 === RUN   TestDumper_doubleclose
wasm_exec.js:54 --- PASS: TestDumper_doubleclose (0.00s)
wasm_exec.js:54 === RUN   TestDumper_earlyclose
wasm_exec.js:54 --- PASS: TestDumper_earlyclose (0.00s)
wasm_exec.js:54 === RUN   TestDump
wasm_exec.js:54 --- PASS: TestDump (0.00s)
wasm_exec.js:54 === RUN   ExampleEncode
wasm_exec.js:54 pipe: not implemented on js
wasm_exec.js:76 exit code: 1

@neelance @bradfitz

Is this issue in syscall side or wasm_exec side ? I am not very clear on that. But there is clearly something which changed with this commit, that is preventing the tests from running.

@agnivade agnivade added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 8, 2018
@agnivade agnivade added this to the Go1.12 milestone Oct 8, 2018
@agnivade agnivade added the arch-wasm WebAssembly issues label Oct 8, 2018
Copy link

Change mentions this issue: misc/wasm: fix fs operations in browser

neelance added a commit to neelance/go that referenced this issue Oct 10, 2018
The commit 0e4c013 changed the syscall package so it uses the
asynchronous functions of Node.js's fs module.

This commit adapts the stubs of the fs module which are used when using
a browser instead of Node.js.

Fixes golang#28068.

Change-Id: Ic3a6a8aebb0db06402383bc2fea7642a4501e02c
@golang golang locked and limited conversation to collaborators Oct 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
arch-wasm WebAssembly issues FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
None yet

No branches or pull requests

2 participants