Giter VIP home page Giter VIP logo

Comments (11)

paralin avatar paralin commented on September 21, 2024 1

I haven't had a chance yet but will try to get to it soon. Try just making a test that fires a callback in 10ms and then end the test successfully after 9ms. Should work if the callback fires just after the test ends.

from wasmbrowsertest.

agnivade avatar agnivade commented on September 21, 2024

Thanks, do you have a reproducer by any chance that I can use?

from wasmbrowsertest.

paralin avatar paralin commented on September 21, 2024

I will try to put one together. In this case I believe the code had run some IndexedDB queries with https://github.com/aperturerobotics/go-indexeddb and then the onsuccess callback was being called after the program had exited.

A possible test case would be to spam callbacks to the Go runtime and then succeed the test. The callback should be able to fire and call into Go wasm (which causes an error in the browser as well) just after the test exits, reproducing the issue.

from wasmbrowsertest.

agnivade avatar agnivade commented on September 21, 2024

@paralin - Just checking if you were able to find some time on this?

from wasmbrowsertest.

paralin avatar paralin commented on September 21, 2024

CI failure examples of this issue:

from wasmbrowsertest.

hajimehoshi avatar hajimehoshi commented on September 21, 2024

I've seen the same issue.

http://127.0.0.1:35499/wasm_exec.js:535:10 Uncaught
Error: Go program has already exited
    at globalThis.Go._resume (http://127.0.0.1:35499/wasm_exec.js:536:11)
    at http://127.0.0.1:35499/wasm_exec.js:264:14
context canceled

https://github.com/hajimehoshi/ebiten/actions/runs/9927011041/job/27421409861

from wasmbrowsertest.

agnivade avatar agnivade commented on September 21, 2024

Thanks Hajime san. This is on my mind. Work has been a bit busy these days.

from wasmbrowsertest.

hajimehoshi avatar hajimehoshi commented on September 21, 2024

We can mitigate the issue by adding a sleep like this:

func TestMain(m *testing.M) {
	code := m.Run()
	time.Sleep(100 * time.Millisecond)
	os.Exit(code)
}

from wasmbrowsertest.

agnivade avatar agnivade commented on September 21, 2024

@hajimehoshi @paralin - I am trying with this:

func TestCallback(t *testing.T) {
	js.Global().Call("setTimeout", js.FuncOf(func(js.Value, []js.Value) interface{} {
		t.Log("hey there")
		return nil
	}), 1000)
	t.Log("done")
}

but unable to reproduce the issue. What am I doing wrong?

from wasmbrowsertest.

agnivade avatar agnivade commented on September 21, 2024

Aha nvm, I am able to repro now. The thing is that the timeout needs to fire between the small window when the test has exited, but the browser hasn't yet unloaded.

Repro case:

func TestCallback(t *testing.T) {
	js.Global().Call("setInterval", js.FuncOf(func(js.Value, []js.Value) interface{} {
		t.Log("hey there")
		return nil
	}), 5)

	t.Log("done")
}

from wasmbrowsertest.

hajimehoshi avatar hajimehoshi commented on September 21, 2024

Thanks!

from wasmbrowsertest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.