Skip to content
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

Wasm/WASI: calling delay() silently exits wasmWasiNodeRun #4239

Closed
OliverO2 opened this issue Sep 28, 2024 · 1 comment
Closed

Wasm/WASI: calling delay() silently exits wasmWasiNodeRun #4239

OliverO2 opened this issue Sep 28, 2024 · 1 comment
Labels

Comments

@OliverO2
Copy link
Contributor

OliverO2 commented Sep 28, 2024

Versions:

  • kotlinx.coroutines 1.9.0
  • Kotlin 2.0.20

Running the following code in commonMain:

import kotlinx.coroutines.delay
import kotlin.time.Duration.Companion.seconds

suspend fun main() {
    println("main: before delay")
    delay(1.seconds)
    println("main: after delay")
}

This works on Wasm/JS,

> Task :wasmJsNodeRun
main: before delay
main: after delay

but silently exits on Wasm/WASI:

> Task :wasmWasiNodeRun
main: before delay
@OliverO2 OliverO2 added the bug label Sep 28, 2024
@dkhalanskyjb
Copy link
Collaborator

Workaround:

import kotlinx.coroutines.delay
import kotlin.time.Duration.Companion.seconds

suspend fun main() {
    withContext(Dispatchers.Default) { }
    println("main: before delay")
    delay(1.seconds)
    println("main: after delay")
}

dkhalanskyjb added a commit that referenced this issue Sep 30, 2024
Before, the event loop was only set when a non-delayed action
was being scheduled.

Fixes #4239
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants