From 29708a1f7cb77f16a31d466f94e8a2f8b5a7a24b Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:34:33 +0700 Subject: [PATCH] clear log from ws-requestor (#1238) * clear log from ws-requestor * wip * wip --- lib/utils/ws-requestor.js | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/lib/utils/ws-requestor.js b/lib/utils/ws-requestor.js index 0a650c2e..9d68dad2 100644 --- a/lib/utils/ws-requestor.js +++ b/lib/utils/ws-requestor.js @@ -132,8 +132,8 @@ class WsRequestor extends BaseRequestor { while (retryCount <= this.maxReconnects) { try { - this.logger.error({retryCount, maxReconnects: this.maxReconnects}, - 'WsRequestor:request - attempting connection'); + this.logger.debug({retryCount, maxReconnects: this.maxReconnects}, + 'WsRequestor:request - attempting connection retry'); // Ensure clean state before each connection attempt if (this.ws) { @@ -141,38 +141,29 @@ class WsRequestor extends BaseRequestor { this.ws = null; } - this.logger.error({retryCount}, 'WsRequestor:request - calling _connect()'); const startAt = process.hrtime(); await this._connect(); const rtt = this._roundTrip(startAt); this.stats.histogram('app.hook.connect_time', rtt, ['hook_type:app']); - this.logger.error({retryCount}, 'WsRequestor:request - connection successful, exiting retry loop'); lastError = null; break; } catch (error) { lastError = error; retryCount++; - this.logger.error({error: error.message, retryCount, maxReconnects: this.maxReconnects}, - 'WsRequestor:request - connection attempt failed'); if (retryCount <= this.maxReconnects && this.retryPolicyValues?.length && this._shouldRetry(error, this.retryPolicyValues)) { - this.logger.error( - {url, error, retryCount, maxRetries: this.maxReconnects}, - `WsRequestor:request - connection failed, retrying (${retryCount}/${this.maxReconnects})` - ); - const delay = this.backoffMs; this.backoffMs = this.backoffMs < 2000 ? this.backoffMs * 2 : (this.backoffMs + 2000); - this.logger.error({delay}, 'WsRequestor:request - waiting before retry'); + this.logger.debug({delay}, 'WsRequestor:request - waiting before retry'); await new Promise((resolve) => setTimeout(resolve, delay)); - this.logger.error('WsRequestor:request - retry delay complete, attempting retry'); continue; } - this.logger.error({lastError: lastError.message, retryCount, maxReconnects: this.maxReconnects}, - 'WsRequestor:request - throwing last error'); + + this.logger.error({error: error.message, retryCount, maxReconnects: this.maxReconnects}, + 'WsRequestor:request - all connection attempts failed'); throw lastError; } } @@ -370,7 +361,7 @@ class WsRequestor extends BaseRequestor { this .once('ready', (ws) => { - this.logger.error({retryCount: 'unknown'}, 'WsRequestor:_connect - ready event fired, resolving Promise'); + this.logger.debug('WsRequestor:_connect - ready event fired, resolving Promise'); this.removeAllListeners('not-ready'); if (this.connections > 1) this.request('session:reconnect', this.url); resolve();