You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(core): address review findings on cross-bundle error branding
- Move brands from declared protected static fields into static blocks:
the field declaration reached the .d.mts and TypeScript's protected-member
rule made the constructor types nominally incompatible across the two
packages (typeof ProtocolError from client was unassignable to server's).
Static blocks keep the own runtime property with no type-surface footprint.
- Harden brandedHasInstance against hostile Proxy traps and throwing
accessors: instanceof must not throw where it previously returned false.
- Brand SseError: the migration guide's HTTP-status classification row pairs
instanceof SdkHttpError with instanceof SseError; both are now
cross-bundle-robust (two client copies in one process).
- Lock the cross-version contract in tests (identity, not shape) and document
it plus the both-copies requirement in the changeset and module JSDoc.
Copy file name to clipboardExpand all lines: .changeset/cross-bundle-error-instanceof.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,4 +3,4 @@
3
3
'@modelcontextprotocol/server': patch
4
4
---
5
5
6
-
`instanceof` on the SDK error classes (`ProtocolError` and its typed subclasses, `SdkError`/`SdkHttpError`, `OAuthError`) now works across separately bundled copies of the SDK. The classes match by a stable brand (via `Symbol.hasInstance` and a registry symbol) instead of prototype identity, so a process that uses both `@modelcontextprotocol/client` and `@modelcontextprotocol/server`— a gateway, host, or in-process test — can check errors constructed by either package against the class re-exported by the other. Ordinary prototype-based `instanceof` is preserved as a fallback; user-defined subclasses keep plain prototype semantics.
6
+
`instanceof` on the SDK error classes (`ProtocolError` and its typed subclasses, `SdkError`/`SdkHttpError`, `OAuthError`, and the client's `SseError`) now works across separately bundled copies of the SDK. The classes match by a stable brand (via `Symbol.hasInstance` and a registry symbol) instead of prototype identity, so a process that uses both `@modelcontextprotocol/client` and `@modelcontextprotocol/server`- a gateway, host, or in-process test - can check errors constructed by either package against the class re-exported by the other. Ordinary prototype-based `instanceof` is preserved as a fallback; user-defined subclasses keep plain prototype semantics. Notes: cross-bundle matching requires both copies to be at or after this release; brands assert identity, not field shape, across versions - keep reading fields defensively. As a side effect, a foreign-bundle `SdkError` used as an abort reason is now rethrown as-is instead of being wrapped as a `RequestTimeout`.
0 commit comments