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

Confusing behavior with exceptions inside goroutines #225

Closed
christopherhesse opened this issue May 6, 2015 · 6 comments
Closed

Confusing behavior with exceptions inside goroutines #225

christopherhesse opened this issue May 6, 2015 · 6 comments

Comments

@christopherhesse
Copy link

I have the following code:

package main

import (
    "github.com/gopherjs/gopherjs/js"
)

func main() {
    document := js.Global.Get("document")
    {
        f := func() {
            print("works always")
            panic("uh oh")
        }

        input := document.Call("createElement", "input")
        input.Set("value", "works always")
        input.Set("type", "button")
        input.Set("onclick", f)
        document.Get("body").Call("appendChild", input)
    }

    {
        f := func() {
            go func() {
                print("works once")
                panic("uh oh")
            }()
        }

        input := document.Call("createElement", "input")
        input.Set("value", "works once")
        input.Set("type", "button")
        input.Set("onclick", f)
        document.Get("body").Call("appendChild", input)
    }
}

Included into a page like this:

<!doctype html><html><head></head><body></body><script>%s</script></html>

I am using the newest version of gopherjs from github.

As the code indicates, I create two buttons, the first one produces a message and exception every time I hit it, the second one only works the first time, and I can't think of a reason why that should be. Any ideas?

@neelance
Copy link
Member

neelance commented May 6, 2015

Thanks a lot for reporting!

@christopherhesse
Copy link
Author

Wow, blown away at that turn around time, thanks for the fix!

@christopherhesse
Copy link
Author

Tested and seems to work great!

@dmitshur
Copy link
Member

dmitshur commented May 6, 2015

Wow, blown away at that turn around time, thanks for the fix!

@christopherhesse See slide 26 of my talk about the GopherJS project. :)

@christopherhesse
Copy link
Author

I guess this guy is probably getting sick of all the wows.

@neelance
Copy link
Member

neelance commented May 7, 2015

Please don't stop. That's one of the best things about this project. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants