Skip to content

Release completed webview message reply callbacks - #9050

Open
Henning Dieterichs (hediet) wants to merge 1 commit into
mainfrom
hediet/message-handler-reply-cleanup
Open

Henning Dieterichs (hediet) wants to merge 1 commit into
mainfrom
hediet/message-handler-reply-cleanup

Conversation

@hediet

Copy link
Copy Markdown
Member

Summary

Release message reply callbacks as soon as each request completes instead of retaining them for the lifetime of the webview.

  • Replace the pending-reply record with a Map.
  • Delete an entry before resolving or rejecting its reply.
  • Remove the entry if sending the request throws synchronously.
  • Ignore duplicate/unknown replies rather than dispatching their payload as a command after cleanup.
  • Test pending-entry counts, successful and failed replies, synchronous send failures, and command routing.

This is a standalone fix against main, extracted from #9047 to keep that PR focused on host/context ownership. No host injection, singleton removal, or Component Explorer tooling is included here.

Validation

  • npm run test:webviews: build succeeded; 65 tests passed, including two new cleanup regressions.
  • npm run lint and npm run hygiene passed.
  • Existing quote-reply listener warnings are addressed separately in Fix webview comment and stack action lifecycle #9049.
  • No dependency or lockfile changes.

Use a Map for pending replies, delete entries before settling replies or after a send failure, and ignore late replies instead of dispatching them as commands.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🟢 Approval recommended

The focused implementation matches the stated behavior and includes adequate regression coverage.

0 open findings

What changed in this PR

Updates webview request handling to release completed reply callbacks promptly.

Changes:

  • Stores pending replies in a Map and removes them before settlement.
  • Cleans up synchronous send failures and ignores duplicate or unknown replies.
  • Adds regression coverage for success, rejection, cleanup, and command routing.
File Description
webviews/​common/​message.ts Implements pending-reply lifecycle cleanup.
webviews/​common/​test/​message.test.ts Tests reply cleanup and routing behavior.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

3 participants