diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/BuiltInCommands.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/BuiltInCommands.kt index 98dc7e1df..59ad0522c 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/BuiltInCommands.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/BuiltInCommands.kt @@ -9,6 +9,7 @@ package net.mamoe.mirai.console.command +import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.cancel import kotlinx.coroutines.cancelAndJoin import kotlinx.coroutines.launch @@ -153,7 +154,7 @@ public object BuiltInCommands { sendMessage( "Login failed: ${throwable.localizedMessage ?: throwable.message ?: throwable.toString()}" + if (this is MessageEventContextAware<*>) { - CommandManagerImpl.launch { + CommandManagerImpl.launch(CoroutineName("stacktrace delayer from Login")) { fromEvent.nextMessageOrNull(60.secondsToMillis) { it.message.contentEquals("stacktrace") } } "\n 1 分钟内发送 stacktrace 以获取堆栈信息" diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandSender.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandSender.kt index 62367da11..2ccda6875 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandSender.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/command/CommandSender.kt @@ -11,6 +11,7 @@ package net.mamoe.mirai.console.command +import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.launch import net.mamoe.kjbb.JvmBlockingBridge import net.mamoe.mirai.Bot @@ -89,7 +90,7 @@ public interface CommandSender { ?: "${cause::class.simpleName.orEmpty()}: ${cause.message}" sendMessage(message) // \n\n60 秒内发送 stacktrace 查看堆栈信息 - bot.launch { + bot.launch(CoroutineName("stacktrace delayer from command")) { if (fromEvent.nextMessageOrNull(60_000) { it.message.contentEquals("stacktrace") || it.message.contentEquals("stack") } != null) { diff --git a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginData.kt b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginData.kt index e45e079c0..2f6155afd 100644 --- a/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginData.kt +++ b/backend/mirai-console/src/main/kotlin/net/mamoe/mirai/console/data/AutoSavePluginData.kt @@ -13,6 +13,7 @@ package net.mamoe.mirai.console.data import kotlinx.atomicfu.atomic import kotlinx.coroutines.* +import net.mamoe.mirai.console.internal.command.qualifiedNameOrTip import net.mamoe.mirai.console.internal.plugin.updateWhen import net.mamoe.mirai.console.util.ConsoleExperimentalAPI import net.mamoe.mirai.console.util.ConsoleInternalAPI @@ -53,7 +54,7 @@ public open class AutoSavePluginData private constructor( owner_.coroutineContext[Job]?.invokeOnCompletion { doSave() } if (shouldPerformAutoSaveWheneverChanged()) { - owner_.launch { + owner_.launch(CoroutineName("AutoSavePluginData.timedAutoSave: ${this::class.qualifiedNameOrTip}")) { while (isActive) { delay(autoSaveIntervalMillis_.last) // 定时自动保存一次, 用于 kts 序列化的对象 doSave() @@ -99,7 +100,10 @@ public open class AutoSavePluginData private constructor( public final override fun onValueChanged(value: Value<*>) { debuggingLogger1.error { "onValueChanged: $value" } if (::owner_.isInitialized) { - lastAutoSaveJob_ = owner_.launch(block = updaterBlock) + lastAutoSaveJob_ = owner_.launch( + block = updaterBlock, + context = CoroutineName("AutoSavePluginData.passiveAutoSave: ${this::class.qualifiedNameOrTip}") + ) } }