Skip to content

fix(reliability): prevent webview postMessage crashes and make dispose idempotent#11313

Open
0xMink wants to merge 1 commit intoRooCodeInc:mainfrom
0xMink:fix/postmessage-crash-idempotent-dispose
Open

fix(reliability): prevent webview postMessage crashes and make dispose idempotent#11313
0xMink wants to merge 1 commit intoRooCodeInc:mainfrom
0xMink:fix/postmessage-crash-idempotent-dispose

Conversation

@0xMink
Copy link

@0xMink 0xMink commented Feb 8, 2026

Closes: #11311

Summary

  • Idempotent dispose(): Added _disposed guard so repeated calls (e.g. during rapid extension deactivation) are no-ops.
  • Catch postMessageToWebview() rejections: Wrapped webview.postMessage() in try/catch so messages sent after the webview is disposed do not surface as unhandled promise rejections.
  • Tests + mock maintenance: Two new tests covering both fixes. Updated the CloudService mock to include off() — a pre-existing gap exposed by the new dispose test.

Test plan

  • postMessageToWebview does not throw when webview is disposed
  • dispose() is idempotent — second call is a no-op
  • All 90 existing tests still pass (6 skipped, unchanged)

Roadmap alignment: Reliability First


Important

Make dispose() idempotent and handle promise rejections in postMessageToWebview() in ClineProvider to improve reliability.

  • Behavior:
    • Make dispose() in ClineProvider idempotent by adding _disposed flag to prevent repeated execution.
    • Wrap postMessageToWebview() in ClineProvider with try/catch to handle promise rejections when webview is disposed.
  • Tests:
    • Add test for postMessageToWebview to ensure no error is thrown when webview is disposed.
    • Add test for dispose() to verify it is idempotent and logs only once.
  • Mocks:
    • Update CloudService mock to include off() method in ClineProvider.spec.ts.

This description was created by Ellipsis for e0808ae. You can customize this summary. It will automatically update as commits are pushed.

…e idempotent

Closes: RooCodeInc#11311

1. postMessageToWebview() now catches rejections from
   webview.postMessage() so that messages sent after the webview is
   disposed do not surface as unhandled promise rejections.

2. dispose() is guarded by a _disposed flag so that repeated calls
   (e.g. during rapid extension deactivation) are no-ops.

3. CloudService mock in ClineProvider.spec.ts updated to include
   off() — a pre-existing gap exposed by the new dispose test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Feb 8, 2026
@roomote
Copy link
Contributor

roomote bot commented Feb 8, 2026

Rooviewer Clock   See task

Reviewed the changes. No issues found -- the _disposed guard on dispose() and the try/catch in postMessageToWebview() are clean, minimal fixes that correctly address the reported problems. Tests cover both behaviors.

  • No issues to resolve

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] postMessageToWebview unhandled rejection; dispose() not idempotent

1 participant