WebAssembly and @MainActor – nothing runs

In reality, my main function just exposes a callback to JS that is called later. That part of the machinery works – main exits, and then the callback I’ve set can be called without issue. In my “real” code, the @MainActor Task is then called within that callback, and it does nothing. But it’s equally reproducible without the intermediate step.

In that sense, I have never experienced the issue you’re describing before. Are you referring specifically to Wasm or to Swift in general?

From experience the above pattern has worked fine before in Swift Wasm, but it’s something to consider. Maybe I need to loop the main run loop, but it’d be news to me in Wasm and I didn’t see anything like that in the current examples eg. in the JavaScriptKit repo.