syscall/js.FuncOf creates a function which may be called from JavaScript. syscall/fs_js.go (and probably other places) uses this mechanism to pass a callback to Javascript. The callback writes a value to a channel.
When running under synctest, this results in a cross-bubble channel operation: The channel is created in a synctest bubble, but the JS-executed function which sends to the channel runs outside the bubble, resulting in panic.
The fix might be to make syscall/js.FuncOf synctest-aware, so that callbacks run in the creators' bubble. But we'll also need to ensure that bubbles don't idle while a JS call is in progress. Possibly mark the bubble as active until FuncOf.Release is called?
The following problem appears in https://go.dev/cl/630382.
syscall/js.FuncOf creates a function which may be called from JavaScript. syscall/fs_js.go (and probably other places) uses this mechanism to pass a callback to Javascript. The callback writes a value to a channel.
When running under synctest, this results in a cross-bubble channel operation: The channel is created in a synctest bubble, but the JS-executed function which sends to the channel runs outside the bubble, resulting in panic.
The fix might be to make syscall/js.FuncOf synctest-aware, so that callbacks run in the creators' bubble. But we'll also need to ensure that bubbles don't idle while a JS call is in progress. Possibly mark the bubble as active until FuncOf.Release is called?