Skip to content

Replace TimeoutCancellationException with TimeoutExceptionΒ #1374

Open
@qwwdfsad

Description

@qwwdfsad

In the current version of the library, withTimeout throws TimeoutCancellationException when a timeout was exceeded.

It can lead to very subtle errors, for example:

launch {
    val result = withTimeout(...) {
        // ... some computation ...
    }
    // process result
}

TimeoutCancellationException is CancellationException, thus is never reported.
But in the snippet above, it's likely to be a programmatic error. If it is expected to miss the deadline, then withTimeoutOrNull should be used explicitly.

My proposal is deprecation of TimeoutCancellationException and replacement with TimeoutException that is not CancellationException

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions