wasm, jsFunc, promises, blocking, sync vs async... quick question
200 views
Skip to first unread message
atd...@gmail.com
unread,
Jul 12, 2025, 11:26:55 AM7/12/25
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Hello,
Quick question. A JS function that calls into Go code via a Func wrapper (meaning it was defined in Go wasm code) is not allowed to block.
Reason being that its execution blocks the event loop.
Could that be relaxed so that we can cooperatively yield back to javascript?
I am not sure it makes sense but I think I have a use case: I want a synchronous wrapper around indexedDB which is an async javascript API.
Originally, the idea was to block in wasm until the indexedDB promise resolved and called back into go to unblock the goroutine. But if I block in wasm, the promise can't resolve because the event loop is also blocked and Promises are async and as such require the event loop. If the promise can't run it can't unblock the goroutine. If the goroutine can't be unblocked, then the event loop can't either. DEADLOCK! :s
Any idea? Does it make sense?
atd...@gmail.com
unread,
Jul 12, 2025, 12:10:43 PM7/12/25
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message