Skip to content

fix: release automatic resize observers on app disconnect - #814

Closed
er-s-an wants to merge 1 commit into
modelcontextprotocol:mainfrom
er-s-an:fix/cleanup-auto-resize-on-disconnect
Closed

er-s-an wants to merge 1 commit into
modelcontextprotocol:mainfrom
er-s-an:fix/cleanup-auto-resize-on-disconnect

Conversation

@er-s-an

@er-s-an er-s-an commented Oct 19, 2026

Copy link
Copy Markdown

Problem

App.connect() calls setupSizeChangedNotifications() but discards its cleanup function. Closing either side of the transport leaves the automatic resize observer subscribed; reconnecting the same App creates another subscription.

Change

Retain the automatic cleanup and invoke it from the SDK's protected transport-close hook. Clear the reference first so it runs once, and delegate to the base hook in finally to preserve protocol teardown and the user's onclose callback.

This is separate from #728's portal measurement and pending-animation-frame cleanup: this patch makes the connection invoke cleanup, without changing the implementation of manual resize setup. An already queued animation frame can still run after disconnect.

Validation

  • New tests use real in-memory protocol connections and a stub resize setup to verify local close, peer close, repeated close, reconnection, and the user's close callback.
  • Before the fix: 2 new tests fail, 14 existing focused tests pass.
  • After: focused suite 16 passed; complete npm test 440 passed, 2 skipped, 0 failed.
  • npm run build, scoped Prettier formatting and git diff --check pass.
  • Independently reviewed and rerun. Browser/E2E observer behavior was not exercised.

AI assistance: implemented and independently reviewed with OpenAI Codex.

@er-s-an

er-s-an commented Oct 20, 2026

Copy link
Copy Markdown
Author

Closing this to keep my open PRs focused, since it hasn't gotten traction. Thanks for maintaining the project. Happy to reopen if it's still useful.

@er-s-an er-s-an closed this Oct 20, 2026
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