W. Michael Petullo
unread,Nov 17, 2020, 3:37:38 AM11/17/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golan...@googlegroups.com
I am having trouble understanding the model for Goroutines within
WebAssembly.
I have a "click" callback with the following form:
errChan := make(chan error, 1)
go func() {
// Call http.PostForm and read response.
if err != nil {
errChan <- err
return
}
// ...
}()
select {
case err := <-errChan:
if err != nil {
// Handle error.
}
case <-time.After(timeout):
// Handle timeout.
}
I had expected http.PostForm to proceed, with the timeout expiring only
if http.PostForm took too long. Yet it seems that http.PostForm blocks
until after the timeout expires. Indeed, the http.PostForm call will not
return until the timer expires, no matter what value I set the timer to.
I setup the above callback (named fork) using:
wasm.AddEventListener(link, "click", js.FuncOf(
func(this js.Value, args []js.Value) interface{} {
return js.FuncOf(fork).Invoke(file)
}))
Does anyone have any recommended reading for performing HTTP requests
from WebAssembly callbacks?
--
Mike
:wq