question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Timelimiter for suspendFunction is throwing timeout exception even when the coroutine was cancelled due to a different reason

See original GitHub issue

Resilience4j 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:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
RobWincommented, May 17, 2021

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.

0reactions
tekenercommented, Feb 1, 2022

After upgrading resilience4j-kotlin to 1.7.1 the issue was fixed for me

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found