ext-apps/src
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Olivier Chafik f615123711
Add double-connect guard to prevent protocol message handling errors (#450)
* fix: guard against double-connect in App and AppBridge (#429)

Calling connect() twice on the same transport instance caused the MCP
SDK's Protocol class to chain onmessage handlers, so each incoming
message was processed twice. This made incoming responses get consumed
by the first processing (resolving the handler) and then trigger a
spurious "Received a response for an unknown message ID" error on the
second processing pass, since the handler was already removed from the
response map.

Add an explicit guard in both App.connect() and AppBridge.connect() that
throws if the instance is already connected. This converts the silent
message-corruption into a clear, actionable error and prevents
downstream confusion.

Adds three regression tests:
- AppBridge.connect() throws when already connected
- App.connect() throws when already connected
- Demonstrates the double-processing root cause and verifies it is fixed

Fixes #429

https://claude.ai/code/session_01XU3FW1TpjBkyRbkBUH5gqR

* test: replace redundant regression test with cleaner same-transport guard check

The previous third test in "double-connect guard" never actually attempted
a double-connect — it created fresh instances and verified normal operation,
which every other test already covers. The stray bridge.onupdatemodelcontext
and bridgeTransport.close() at the top were leftover noise.

Replace it with a focused test that verifies the guard fires even when
the caller passes the *same* transport object (not just a different one),
which is the exact scenario described in #429.

https://claude.ai/code/session_01XU3FW1TpjBkyRbkBUH5gqR

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-02-17 18:15:24 +00:00
..
generated Replace "external" with "network" in CSP documentation 2026-02-02 10:50:06 -06:00
react Improve patterns guide with concrete examples and safe area insets 2026-01-27 17:32:41 -06:00
server Clarify spec and SDK: accept UIResourceMeta in both resources/list and resources/read (#410) 2026-02-04 14:26:09 +00:00
app-bridge.examples.ts docs: standardize UI terminology to use "view" consistently (#325) 2026-01-23 04:36:52 +02:00
app-bridge.test.ts Add double-connect guard to prevent protocol message handling errors (#450) 2026-02-17 18:15:24 +00:00
app-bridge.ts Add double-connect guard to prevent protocol message handling errors (#450) 2026-02-17 18:15:24 +00:00
app.examples.ts Improve patterns guide with concrete examples and safe area insets 2026-01-27 17:32:41 -06:00
app.ts Add double-connect guard to prevent protocol message handling errors (#450) 2026-02-17 18:15:24 +00:00
message-transport.examples.ts docs: standardize UI terminology to use "view" consistently (#325) 2026-01-23 04:36:52 +02:00
message-transport.ts fix(message-transport): only ignore messages that lack jsonrpc: "2.0" (#448) 2026-02-12 15:28:32 +00:00
spec.types.ts Replace "external" with "network" in CSP documentation 2026-02-02 10:50:06 -06:00
styles.examples.ts Improve patterns guide with concrete examples and safe area insets 2026-01-27 17:32:41 -06:00
styles.ts Improve patterns guide with concrete examples and safe area insets 2026-01-27 17:32:41 -06:00
types.ts feat(server): add getUiCapability helper for capability negotiation (#313) 2026-01-23 16:26:49 +00:00