Skip to content

[BUGFIX] Fix incorrect cancellation propagation#10

Merged
tiper merged 12 commits intomainfrom
bugfix/cancellation_propagation
Mar 7, 2026
Merged

[BUGFIX] Fix incorrect cancellation propagation#10
tiper merged 12 commits intomainfrom
bugfix/cancellation_propagation

Conversation

@tiper
Copy link
Copy Markdown
Owner

@tiper tiper commented Mar 6, 2026

No description provided.

@tiper tiper self-assigned this Mar 6, 2026
Copilot AI review requested due to automatic review settings March 6, 2026 22:55
@tiper tiper force-pushed the bugfix/cancellation_propagation branch from 82bc0d2 to d540b8d Compare March 6, 2026 22:56
Fix issue where CancellationException was being incorrectly propagated
@tiper tiper force-pushed the bugfix/cancellation_propagation branch from d540b8d to 694d51b Compare March 6, 2026 22:57
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the cancellation handling in the RequestDeduplication Ktor client plugin. The previous implementation used a SupervisorJob and CoroutineScope with scope.launch to isolate the first caller's HTTP request from cancellation propagation. The new implementation removes the separate scope entirely, running the request inline in the first caller's coroutine, and introduces a retry mechanism for non-first callers that catch a CancellationException from the shared deferred when their own coroutine is still active.

Changes:

  • Removed SupervisorJob, CoroutineScope, Job, and launch in favor of running the HTTP request inline in the first caller's coroutine, with a new execute extension function on Send.Sender.
  • Added CancellationException handling for non-first callers: if the shared deferred fails with cancellation but the waiter's coroutine is still active, it retries with a fresh HTTP call.
  • Simplified InFlightEntry by removing the job field and changing from data class to class (since identity comparison === is used).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 6, 2026 23:30
@tiper tiper force-pushed the bugfix/cancellation_propagation branch from abb4853 to 7824263 Compare March 6, 2026 23:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tiper tiper force-pushed the bugfix/cancellation_propagation branch from 37a7618 to e026f37 Compare March 7, 2026 00:14
Copilot AI review requested due to automatic review settings March 7, 2026 00:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 7, 2026 09:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings March 7, 2026 09:47
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tiper tiper merged commit c2542f9 into main Mar 7, 2026
3 checks passed
@tiper tiper deleted the bugfix/cancellation_propagation branch March 7, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants