From 85765e45403ff59318f8ab29686010c1e5aa236c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sat, 18 Jul 2026 09:33:23 +0200 Subject: [PATCH] test(driver-multiplatform): Isolate the client into its own coroutine scope to ensure it is completely torn down before continuing --- .../src/commonTest/kotlin/utils/FindHostname.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/driver-multiplatform/src/commonTest/kotlin/utils/FindHostname.kt b/driver-multiplatform/src/commonTest/kotlin/utils/FindHostname.kt index 1bd176cf..18cc607e 100644 --- a/driver-multiplatform/src/commonTest/kotlin/utils/FindHostname.kt +++ b/driver-multiplatform/src/commonTest/kotlin/utils/FindHostname.kt @@ -16,7 +16,7 @@ package opensavvy.ktmongo.multiplatform.utils -import kotlinx.coroutines.currentCoroutineContext +import kotlinx.coroutines.coroutineScope import opensavvy.ktmongo.multiplatform.MongoClient import opensavvy.prepared.suite.cleanUp import opensavvy.prepared.suite.foregroundScope @@ -29,11 +29,13 @@ private suspend fun tryConnect( hostname: String, ): Boolean { try { - println("KtMongo • Attempting to connect to $hostname") - MongoClient(hostname = hostname, coroutineContext = currentCoroutineContext()).close() + println(" Attempting to connect to $hostname") + coroutineScope { + MongoClient(hostname = hostname, coroutineContext = coroutineContext).close() + } return true } catch (e: Throwable) { - println("KtMongo • Could not connect to $hostname: $e") + println(" Could not connect to $hostname: ${e.stackTraceToString()}") return false } } -- 2.51.2