Skip to content

feat: support suspending close callbacks - #965

Open
original4422 wants to merge 1 commit into
modelcontextprotocol:mainfrom
original4422:fix/suspending-on-close-919
Open

feat: support suspending close callbacks#965
original4422 wants to merge 1 commit into
modelcontextprotocol:mainfrom
original4422:fix/suspending-on-close-919

Conversation

@original4422

Copy link
Copy Markdown

Summary

  • change transport, protocol, session, and server close callbacks to suspending callbacks that are awaited by their close paths
  • preserve callback registration order, AbstractTransport's exactly-once behavior, and its existing exception suppression while allowing cleanup to finish after transport-scope cancellation
  • bridge WebSocket and server-SSE completion notifications through lifecycle-owned watcher jobs, including an explicit SSE close path that does not wait for the session Job to finish
  • update public KDoc and API dumps for the intentional breaking API change

Testing

  • ./gradlew :kotlin-sdk-core:jvmTest :kotlin-sdk-client:jvmTest :kotlin-sdk-server:jvmTest :kotlin-sdk-testing:jvmTest
  • ./gradlew ktlintCheck apiCheck detekt
  • ./gradlew apiDump
  • compiled an out-of-repository consumer that calls delay() inside Transport.onClose

Fixes #919

Copilot AI lite review requested due to automatic review settings August 20, 2026 00:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@original4422

Copy link
Copy Markdown
Author

Hi @devcrocod, when you have a chance, would you mind reviewing this PR and letting me know whether any changes are needed? 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.

onClose callbacks are synchronous, so suspending cleanup has nowhere to run

2 participants