Skip to content

Fix blocking http calls which cannot be cancelled#297

Open
olamy wants to merge 1 commit into
segmentio:mainfrom
olamy:fix-blocking-call
Open

Fix blocking http calls which cannot be cancelled#297
olamy wants to merge 1 commit into
segmentio:mainfrom
olamy:fix-blocking-call

Conversation

@olamy

@olamy olamy commented Feb 27, 2026

Copy link
Copy Markdown

The analytics-kotlin library runs blocking OkHttp calls (client.newCall(request).execute()) inside coroutines via withContext and launch, but without runInterruptible. This means Job.cancel() cannot interrupt in-flight HTTP calls the coroutine only cancels at the next suspension point, not during the blocking I/O. Wrapping in runInterruptible causes coroutine cancellation to trigger Thread.interrupt(), which OkHttp handles by aborting the connection immediately.

Signed-off-by: Olivier Lamy olamy@apache.org

@olamy olamy changed the title The analytics-kotlin library runs blocking OkHttp calls (client.newCall(request).execute()) inside coroutines via withContext and launch, but without runInterruptible. This means Job.cancel() cannot interrupt in-flight HTTP calls — the coroutine only cancels at the next suspension point, not during the blocking I/O. Wrapping in runInterruptible causes coroutine cancellation to trigger Thread.interrupt(), which OkHttp handles by aborting the connection immediately. Fix blocking http calls which cannot be cancelled Feb 27, 2026
…ll(request).execute()) inside coroutines via withContext and launch, but without runInterruptible.

This means Job.cancel() cannot interrupt in-flight HTTP calls, the coroutine only cancels at the next suspension point, not during the blocking I/O.
Wrapping in runInterruptible causes coroutine cancellation to trigger Thread.interrupt(), which OkHttp handles by aborting the connection immediately.

Signed-off-by: Olivier Lamy <olamy@apache.org>
@olamy
olamy force-pushed the fix-blocking-call branch from 3f9034f to 8ed4311 Compare February 27, 2026 05:40
@olamy
olamy marked this pull request as ready for review February 28, 2026 03:48
@apuig

apuig commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Hi @wenxi-zeng ! Since this PR has been approved, is there an ETA for cutting a release that will include it? Thanks!

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.

3 participants