Skip to content

fix: cancel pending size notifications on manual cleanup - #815

Open
po-et wants to merge 1 commit into
modelcontextprotocol:mainfrom
po-et:fix/cancel-pending-resize-frame
Open

po-et wants to merge 1 commit into
modelcontextprotocol:mainfrom
po-et:fix/cancel-pending-resize-frame

Conversation

@po-et

@po-et po-et commented Oct 20, 2026

Copy link
Copy Markdown

Calling the cleanup returned by App.setupSizeChangedNotifications() disconnects the ResizeObserver, but an animation frame already scheduled by setup or a resize still runs. It measures the document and can send a ui/notifications/size-changed notification after the caller has disabled these notifications.

Keep the pending frame ID and cancel it during cleanup, including frame ID 0. Existing resize coalescing is preserved. Regression tests connect an App to an SDK Server through InMemoryTransport and cover cleanup before the initial frame and a later resize frame, repeated cleanup, and setup again on the same connected App.

Related work: #814 handles invoking cleanup when a connection closes and explicitly leaves pending animation frames outside its scope. Closed, unmerged #728 previously included frame cancellation as part of a broader portal-height and MutationObserver change. This PR isolates that cleanup behavior on current main; it does not change connection ownership or the height-measurement algorithm.

Validation:

  • Baseline: both new regression cases fail because measurement still occurs after cleanup.
  • bun test src/app.test.ts: 16 passed.
  • bun test src examples: 441 passed, 1 skipped.
  • TypeScript, repository Prettier check, strict TypeDoc validation, and schema/snippet regeneration passed; generated files did not change.
  • SDK declarations and all bundle entry points built using the repository build recipe with its destructive output-directory cleanup omitted. Browser E2E and all-example builds were not run.

AI assistance: OpenAI Codex generated the implementation, tests, and this description. Independent automated review is recorded separately; this disclosure does not claim personal human review.

This branch has not been deployed

No deployments
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