From 77a2f7683fc003e1d5ba7c240a19be5307e746dd Mon Sep 17 00:00:00 2001 From: Ivan “CLOVIS” Canet Date: Tue, 07 Jul 2026 18:30:38 +0000 Subject: [PATCH] test(driver-multiplatform): Launch the client in the foreground scope The background scope auto-cancels everything. By using the foreground scope, it will be more visible if something is not properly cancelled. --- driver-multiplatform/src/commonTest/kotlin/utils/FindHostname.kt | 13 ++++++++++--- 1 file(s) changed, 10 insertion(s)(+), 3 deletion(s)(-) diff --git a/driver-multiplatform/src/commonTest/kotlin/utils/FindHostname.kt b/driver-multiplatform/src/commonTest/kotlin/utils/FindHostname.kt --- a/driver-multiplatform/src/commonTest/kotlin/utils/FindHostname.kt +++ b/driver-multiplatform/src/commonTest/kotlin/utils/FindHostname.kt @@ -21,7 +21,8 @@ import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.job import opensavvy.ktmongo.multiplatform.MongoClient -import opensavvy.prepared.suite.backgroundScope +import opensavvy.prepared.suite.cleanUp +import opensavvy.prepared.suite.foregroundScope import opensavvy.prepared.suite.prepared import opensavvy.prepared.suite.shared import kotlin.concurrent.atomics.ExperimentalAtomicApi @@ -55,9 +56,15 @@ val MongoClient by prepared { val address = mongoAddress() - MongoClient( + val client = MongoClient( hostname = address, port = 27017, - coroutineContext = backgroundScope.coroutineContext, + coroutineContext = foregroundScope.coroutineContext, ) + + cleanUp("MongoClient") { + client.close() + } + + client } -- tangled.sh