Skip to content

Cancel OkHttp WebSocket when connect is canceled - #16

Open
masaru87 wants to merge 1 commit into
FairyDevicesRD:mainfrom
masaru87:fix/okhttp-connect-cancellation
Open

Cancel OkHttp WebSocket when connect is canceled#16
masaru87 wants to merge 1 commit into
FairyDevicesRD:mainfrom
masaru87:fix/okhttp-connect-cancellation

Conversation

@masaru87

@masaru87 masaru87 commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • close the receive channel when connect is canceled during the WebSocket handshake
  • let the existing channel close handler cancel the underlying OkHttp WebSocket
  • preserve and rethrow the original CancellationException
  • add a regression test for cancellation while opening

Previously, canceling the coroutine suspended in connect stopped only the caller. The OkHttp WebSocket connection attempt remained active because neither the receive channel nor the socket was canceled.

Testing

  • ./gradlew :engine:okhttp:test --no-daemon
  • ./gradlew jvmTest --no-daemon

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.

1 participant