swift
swift copied to clipboard
`main` function in `@main` types fails with error
Describe the bug This sample code fails immediately after it starts executing:
import JavaScriptEventLoop
@main
enum Main {
static func main() async throws {
JavaScriptEventLoop.installGlobalExecutor()
}
}
Screenshots

Environment
SwiftWasm 5.6.0, carton 0.16.1
It's expected behavior because async_Main calls exit(0) at the end of the initial job.
My concern here is that uncaught JS error may lead to some unexpected/incorrect state, or at least confuse users. Maybe we should detect this specific exit(0) in our entrypoint code to make sure it's handled appropriately?
@MaxDesiatov Yes, that should be handled by instance startup JS code.