From 68fe2a9e7bef13462bd304d0d4b55f3afec1b5db Mon Sep 17 00:00:00 2001 From: "Marc J. Schmidt" Date: Tue, 5 Dec 2023 10:01:13 +0100 Subject: [PATCH] fix(rpc): defer resolving class name so that reflection (reflect()) is not called in bootstrap/decorator code. this will lead to undefined references when circular structure is given. --- packages/rpc/src/decorators.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/rpc/src/decorators.ts b/packages/rpc/src/decorators.ts index 57934dffe..be640c2e7 100644 --- a/packages/rpc/src/decorators.ts +++ b/packages/rpc/src/decorators.ts @@ -23,12 +23,15 @@ class RpcController { // Defaults to the name of the class name: string = ''; + classType?: ClassType; + definition?: ControllerDefinition; actions = new Map(); 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 : ''); } } @@ -59,7 +62,7 @@ class RpcClass { } onDecorator(classType: ClassType) { - this.t.name ||= reflect(classType).typeName || classType.name; + this.t.classType = classType; } }