Rob Murdock
07/12/2024, 2:30 AMRob Murdock
07/12/2024, 2:32 AMRob Murdock
07/12/2024, 2:33 AM@Test
fun pleaseDontExplode() = runTest {
val scopes = generateSequence { MainScope() }.take(10)
scopes
.map { it.async { println("running job") } }
.forEach { it.await() }
scopes.forEach { it.cancel() }
}
Rob Murdock
07/12/2024, 2:33 AMRob Murdock
07/12/2024, 2:34 AMturansky
07/12/2024, 9:50 AMforEach
for Sequence
? 😉
Should it work in fact? 😀Rob Murdock
07/12/2024, 12:27 PMRob Murdock
07/12/2024, 12:27 PMRob Murdock
07/12/2024, 12:28 PMRob Murdock
07/12/2024, 12:43 PM@OptIn(DelicateCoroutinesApi::class)
@Test
fun pleaseDontExplode() = GlobalScope.promise {
val scopes = generateSequence { MainScope() }.take(15).toList()
scopes
.map { it.async { println("running job") } }
.forEach { it.await(); println("completed job") }
println("test completed - 1")
scopes.forEach { it.cancel() }
println("test completed")
}
Interestingly, this also produces the problem. Possibly a strange interaction with mocha and js coroutines.
when the problem happens, it looks like the job runs, completes the lambda, but never finishes, and this causes everything to hang. That's probably enough investigation for me into this curiosity for nowturansky
07/12/2024, 1:11 PMRob Murdock
07/12/2024, 1:11 PMRob Murdock
07/12/2024, 1:12 PMRob Murdock
07/12/2024, 1:12 PMRob Murdock
07/12/2024, 1:12 PMturansky
07/12/2024, 1:13 PMCoroutineScope(EmptyCoroutineContext)
?Rob Murdock
07/12/2024, 1:13 PMturansky
07/12/2024, 1:13 PMGlobalScope
Rob Murdock
07/12/2024, 1:13 PMRob Murdock
07/12/2024, 1:14 PM