Skip to content

Commit

Permalink
fix(microservices): use instance ref to call handler #13473
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Nov 7, 2024
1 parent bc4667c commit da8ebde
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions packages/microservices/listener-metadata-explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,36 @@ export class ListenerMetadataExplorer {
const instancePrototype = Object.getPrototypeOf(instance);
return this.metadataScanner
.getAllMethodNames(instancePrototype)
.map(method => this.exploreMethodMetadata(instancePrototype, method))
.map(method =>
this.exploreMethodMetadata(instance, instancePrototype, method),
)
.filter(metadata => metadata);
}

public exploreMethodMetadata(
instance: Controller,
instancePrototype: object,
methodKey: string,
): EventOrMessageListenerDefinition {
const targetCallback = instancePrototype[methodKey];
const prototypeCallback = instancePrototype[methodKey];
const handlerType = Reflect.getMetadata(
PATTERN_HANDLER_METADATA,
targetCallback,
prototypeCallback,
);
if (isUndefined(handlerType)) {
return;
}
const patterns = Reflect.getMetadata(PATTERN_METADATA, targetCallback);
const transport = Reflect.getMetadata(TRANSPORT_METADATA, targetCallback);
const extras = Reflect.getMetadata(PATTERN_EXTRAS_METADATA, targetCallback);
const patterns = Reflect.getMetadata(PATTERN_METADATA, prototypeCallback);
const transport = Reflect.getMetadata(
TRANSPORT_METADATA,
prototypeCallback,
);
const extras = Reflect.getMetadata(
PATTERN_EXTRAS_METADATA,
prototypeCallback,
);

const targetCallback = instance[methodKey];
return {
methodKey,
targetCallback,
Expand Down

0 comments on commit da8ebde

Please sign in to comment.