Timelimiter for suspendFunction is throwing timeout exception even when the coroutine was cancelled due to a different reason
See original GitHub issueResilience4j version: 1.7.0
Java version: 11
Timelimiter for suspendFunction is throwing timeout exception even when the coroutine was cancelled due to different reason.
Suppose due to some business logic, we need to cancel a particular “time limited” suspend function using something like Defferred.cancel(BusinessCancellationException("Do not require this computation anymore"))
, then this should not be treated as a failure for the timelimiter and should not be converted to a timeout exception but currently it does.
code here converts all cancellation exceptions to timeoutExceptions:
catch (t: Throwable) {
if (isCancellation(coroutineContext, t)) {
val timeoutException = TimeLimiter.createdTimeoutExceptionWithName(name, t)
onError(timeoutException)
throw timeoutException
}
onError(t)
throw t
}
I would propose to specifically do this only for TimeoutCancellationException.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Cancellation and timeouts | Kotlin
This section covers coroutine cancellation and timeouts. ... for cancellation of coroutine and throw CancellationException when cancelled.
Read more >Implementing Timeouts with Resilience4j - Reflectoring
When a timeout occurs, it cancels the running Future before throwing a TimeoutException . Using the Resilience4j TimeLimiter Module.
Read more >Getting Started - resilience4j
Integration for Kotlin coroutines that enables executing and decorating ... is ignored - on timeout, the suspend function is always cancelled even if...
Read more >kotlin coroutine withTimeout does not cancel when using ...
Just call Thread.currentThread().interrupt() where you catch TimeoutCancellationException . That will cause the runBlocking to exit with an ...
Read more >Kotlin Coroutines -Cancellation And Timeout | by Sarah Maher
why did the original call to the api got canceled without any of these two approaches ? that is because each suspend function...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Unfortunately not. Because Bintray was shut down and we need to migrate the whole release process to Maven Central first 😦 We didn’t have time yet.
After upgrading
resilience4j-kotlin
to 1.7.1 the issue was fixed for me