fix(client): guard notification wiring against non-function prototype props#19
Merged
kauandotnet merged 1 commit intomainfrom Apr 23, 2026
Merged
Conversation
… props
McpClientBootstrap.wireNotificationHandlers iterates each provider's
prototype own-property names and calls Reflect.getMetadata with the
value at each key. When any provider in the DI graph has a prototype
whose own-property list includes a non-function (e.g. plain-object
providers registered via useValue where the prototype is
Object.prototype and Object.prototype.__proto__ resolves to null, or
library classes with accessor properties returning primitives),
Reflect.getMetadata throws TypeError because its target must be an
object. This blocked any app combining McpClientModule with common
useValue: {} config providers.
Skip prototype entries whose value is not a function before looking up
metadata.
Fixes #18
|
To view this pull requests documentation preview, visit the following URL: Documentation is deployed and generated using docs.page. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
McpClientBootstrap.wireNotificationHandlersthrowingTypeErrorwhen any provider in the DI graph has a prototype whosegetOwnPropertyNameslist includes a non-function value (e.g.useValue: {}providers, whose prototype isObject.prototypeandObject.prototype.__proto__resolves tonull).typeof method !== 'function'guard before theReflect.getMetadatacall, hoistingprototype[methodName]into a local.nulland a primitive data property, asserting bootstrap resolves and the real handler still wires.Test plan
cd packages/client && pnpm test— 202/202 pass (new test + 201 existing)TypeErroratReflect.js:367fromwireNotificationHandlersbefore the guard is applied