diff --git a/packages/core/src/config-manager/service-discovery/ServiceMonitor.ts b/packages/core/src/config-manager/service-discovery/ServiceMonitor.ts index 6af99229f..5757f747d 100644 --- a/packages/core/src/config-manager/service-discovery/ServiceMonitor.ts +++ b/packages/core/src/config-manager/service-discovery/ServiceMonitor.ts @@ -169,15 +169,18 @@ export class ServiceMonitor { private async monitorModules() { for (const module of this._serviceRegistry.getRegisteredModules()) { - const registeredModule = this._serviceRegistry.getModule(module)!; + const registeredModule = this._serviceRegistry.getModule(module); + if (!registeredModule) continue; try { await this.healthCheckService(module, registeredModule.address); } catch (e) { - this.handleUnresponsiveModule( - module, - registeredModule.address, - HealthCheckStatus.SERVICE_UNKNOWN, - ); + if (this._serviceRegistry.getModule(module)) { + this.handleUnresponsiveModule( + module, + registeredModule.address, + HealthCheckStatus.SERVICE_UNKNOWN, + ); + } } } this.moduleRegister.emit('serving-modules-update'); diff --git a/packages/core/src/config-manager/service-discovery/index.ts b/packages/core/src/config-manager/service-discovery/index.ts index bf80bb102..fa5186be6 100644 --- a/packages/core/src/config-manager/service-discovery/index.ts +++ b/packages/core/src/config-manager/service-discovery/index.ts @@ -137,6 +137,8 @@ export class ServiceDiscovery { this.grpcSdk.createModuleClient(moduleName, moduleUrl); } } catch (e) { + ConduitGrpcSdk.Logger.error(`SD: failed to recover: ${moduleName} ${moduleUrl}`); + ConduitGrpcSdk.Logger.error(`SD: recovery error: ${e}`); throw new Error('Failed to register unresponsive module'); } const healthStatus = healthResponse.status as unknown as HealthCheckStatus;