From c8def70594ab13b7ec964efea3ae444c33e24438 Mon Sep 17 00:00:00 2001
From: Him188 <Him188@mamoe.net>
Date: Tue, 8 Jun 2021 12:39:36 +0800
Subject: [PATCH] Add `bot.job` as parent of `NetworkHandlerSupport`

---
 .../kotlin/network/handler/NetworkHandlerSupport.kt       | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mirai-core/src/commonMain/kotlin/network/handler/NetworkHandlerSupport.kt b/mirai-core/src/commonMain/kotlin/network/handler/NetworkHandlerSupport.kt
index 7afe0f993..d55de8416 100644
--- a/mirai-core/src/commonMain/kotlin/network/handler/NetworkHandlerSupport.kt
+++ b/mirai-core/src/commonMain/kotlin/network/handler/NetworkHandlerSupport.kt
@@ -32,9 +32,11 @@ import kotlin.reflect.KClass
  * Implements basic logics of [NetworkHandler]
  */
 internal abstract class NetworkHandlerSupport(
-    override val context: NetworkHandlerContext,
-    coroutineContext: CoroutineContext = EmptyCoroutineContext,
-) : NetworkHandler, CoroutineScope by coroutineContext.childScope(SupervisorJob()) {
+    final override val context: NetworkHandlerContext,
+    additionalCoroutineContext: CoroutineContext = EmptyCoroutineContext,
+) : NetworkHandler, CoroutineScope {
+    final override val coroutineContext: CoroutineContext =
+        additionalCoroutineContext.childScopeContext(SupervisorJob(context.bot.coroutineContext.job))
 
     protected abstract fun initialState(): BaseStateImpl
     protected abstract suspend fun sendPacketImpl(packet: OutgoingPacket)