Skip to content

fix(mcp): contain synchronous run-code listener exceptions - #43708

Closed
Anirudh Sharma (anirudhqwerty) wants to merge 5 commits into
microsoft:mainfrom
anirudhqwerty:fix-1803
Closed

Anirudh Sharma (anirudhqwerty) wants to merge 5 commits into
microsoft:mainfrom
anirudhqwerty:fix-1803

Conversation

@anirudhqwerty

Copy link
Copy Markdown

References #43770. Alternative to #43686 with containment scoped to callbacks created in browser_run_code_unsafe VM contexts.

  • Catch synchronous exceptions at callback invocation and report them through the existing MCP error queue, keeping the server and session usable after the registration call returns.
  • Preserve ordinary host callback exceptions, listener identity, async rejection handling, and errors during once cleanup. Weak-key registration and context disposal control the error scope's lifetime.
  • Add regression coverage for delayed callbacks, error visibility, follow-up requests, listener removal, and disposal without a process-level exception handler.

Evidence: baseline crash reproduction, Windows verification: 19 MCP and 55 event tests, and final Linux build and full flint. Windows tested the same executable code and tests; the final source commit adds only the required test-catalog entries. Functional coverage is Chromium only; macOS and performance/heap stress were not tested.

@anirudhqwerty

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

for (const listener of this._unhandledRejectionListeners)
listener(reason);
};
readonly runCodeListenerErrors = new ListenerErrorScope(this._onUnhandledRejection);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We don't want some extra private API between library and mcp tools.

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.

2 participants