-
Notifications
You must be signed in to change notification settings - Fork 18k
misc/wasm: deadlock from http.Get in syscall/js.FuncOf #37136
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
Comments
Thank you for reporting this issue @QFleet and welcome to the Go project! Kindly pinging some WASM experts @neelance @cherrymui |
i move the http request into main(), not in syscall/js.FuncOf. i can get the response from console log. there is only the deadlock of http request in syscall/js.FuncOf |
The doc of FuncOf, https://golang.org/pkg/syscall/js/#FuncOf , said that blocking operations in the wrapped function will block the event loop. So I think you want to move blocking operations out of FuncOf, e.g. to main as you did. |
Thank you for the investigation and diagnosis @cherrymui! @QFleet this is working as intended and as recommended by that docs and reiterated by @cherrymui, please don’t put blocking operations in FuncOf. I shall close this issue but please don’t hesitate to open others, and I hope to see you even more in that community. Thank you. |
thanks a lot @cherrymui @odeke-em background: i have huge amounts of data with different source by socketFuncOf is the simple collector for params in my opinion, the real logic in another goroute(maybe many)? do you have any idea? there are 2 methods in my opinion as below:
goObj.Set("getDataByHttp1", js.FuncOf(func(this js.Value, args []js.Value) interface{} { jquery := js.Global().Get("$") if jquery != js.Undefined() { rtn := jquery.Get("ajax").Invoke("http://localhost:3000/demo.json") return rtn } return nil })) |
@cherrymui $ web.js goObj.httpGo().then(function(res){ console.log(res);}); thanks for your reply, |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I want hide my http request in go-wasm as the js-lib, my js code call go-wasm do the http request. See my demo as below:
What did you expect to see?
exprect to see the demo.json in console log.
What did you see instead?
log as below:
The text was updated successfully, but these errors were encountered: