mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-31 19:40:24 +08:00
Fix HB logic: catch TimeoutCancellationException from HB action and report it as non-fatal error. Fix #2024
This commit is contained in:
parent
71fb5585fe
commit
0d3bc9c684
@ -114,18 +114,26 @@ internal class TimeBasedHeartbeatSchedulerImpl(
|
||||
}
|
||||
|
||||
try {
|
||||
val result = withTimeoutOrNull(timeout()) { action() }
|
||||
var cause: Throwable? = null
|
||||
val result = try {
|
||||
withTimeoutOrNull(timeout()) { action() }
|
||||
} catch (e: TimeoutCancellationException) {
|
||||
// from `action`
|
||||
cause = e
|
||||
null
|
||||
}
|
||||
if (result == null) {
|
||||
onHeartFailure(
|
||||
name,
|
||||
PacketTimeoutException(
|
||||
"$coroutineName: Timeout receiving action response",
|
||||
CancellationException("Dummy exception for stacktrace")
|
||||
cause
|
||||
) // This is a NetworkException that is recoverable
|
||||
)
|
||||
return@async
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
// catch other errors
|
||||
onHeartFailure(
|
||||
name,
|
||||
IllegalStateException("$coroutineName: Internal error: caught unexpected exception", e)
|
||||
|
Loading…
Reference in New Issue
Block a user