Skip to content

Commit

Permalink
fix(rpc): defer resolving class name
Browse files Browse the repository at this point in the history
so that reflection (reflect()) is not called in bootstrap/decorator code. this will lead to undefined references when circular structure is given.
  • Loading branch information
marcj committed Dec 5, 2023
1 parent 2f12c2e commit 68fe2a9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/rpc/src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ class RpcController {
// Defaults to the name of the class
name: string = '';

classType?: ClassType;

definition?: ControllerDefinition<any>;

actions = new Map<string, RpcAction>();

getPath(): string {
return this.definition ? this.definition.path : this.name;
const name = this.definition ? this.definition.path : this.name;
return name || (this.classType ? reflect(this.classType).typeName || this.classType.name : '');
}
}

Expand Down Expand Up @@ -59,7 +62,7 @@ class RpcClass {
}

onDecorator(classType: ClassType) {
this.t.name ||= reflect(classType).typeName || classType.name;
this.t.classType = classType;
}
}

Expand Down

0 comments on commit 68fe2a9

Please sign in to comment.