diff --git a/packages/common/module-utils/configurable-module.builder.ts b/packages/common/module-utils/configurable-module.builder.ts index 29a31eb04b9..dc2f8eec694 100644 --- a/packages/common/module-utils/configurable-module.builder.ts +++ b/packages/common/module-utils/configurable-module.builder.ts @@ -209,7 +209,7 @@ export class ConfigurableModuleBuilder< const providers: Array = [ { provide: self.options.optionsInjectionToken, - useFactory: () => this.omitExtras(options, self.extras), + useValue: this.omitExtras(options, self.extras), }, ]; if (self.options.alwaysTransient) { diff --git a/packages/microservices/module/clients.module.ts b/packages/microservices/module/clients.module.ts index dad7c69f231..4026bbab308 100644 --- a/packages/microservices/module/clients.module.ts +++ b/packages/microservices/module/clients.module.ts @@ -20,8 +20,7 @@ export class ClientsModule { const clients = (clientsOptions || []).map(item => { return { provide: item.name, - useFactory: () => - this.assignOnAppShutdownHook(ClientProxyFactory.create(item)), + useValue: this.assignOnAppShutdownHook(ClientProxyFactory.create(item)), }; }); return {