mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-21 09:08:02 +00:00
clear log from ws-requestor (#1238)
* clear log from ws-requestor * wip * wip
This commit is contained in:
@@ -132,8 +132,8 @@ class WsRequestor extends BaseRequestor {
|
|||||||
|
|
||||||
while (retryCount <= this.maxReconnects) {
|
while (retryCount <= this.maxReconnects) {
|
||||||
try {
|
try {
|
||||||
this.logger.error({retryCount, maxReconnects: this.maxReconnects},
|
this.logger.debug({retryCount, maxReconnects: this.maxReconnects},
|
||||||
'WsRequestor:request - attempting connection');
|
'WsRequestor:request - attempting connection retry');
|
||||||
|
|
||||||
// Ensure clean state before each connection attempt
|
// Ensure clean state before each connection attempt
|
||||||
if (this.ws) {
|
if (this.ws) {
|
||||||
@@ -141,38 +141,29 @@ class WsRequestor extends BaseRequestor {
|
|||||||
this.ws = null;
|
this.ws = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.error({retryCount}, 'WsRequestor:request - calling _connect()');
|
|
||||||
const startAt = process.hrtime();
|
const startAt = process.hrtime();
|
||||||
await this._connect();
|
await this._connect();
|
||||||
const rtt = this._roundTrip(startAt);
|
const rtt = this._roundTrip(startAt);
|
||||||
this.stats.histogram('app.hook.connect_time', rtt, ['hook_type:app']);
|
this.stats.histogram('app.hook.connect_time', rtt, ['hook_type:app']);
|
||||||
this.logger.error({retryCount}, 'WsRequestor:request - connection successful, exiting retry loop');
|
|
||||||
lastError = null;
|
lastError = null;
|
||||||
break;
|
break;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
lastError = error;
|
lastError = error;
|
||||||
retryCount++;
|
retryCount++;
|
||||||
this.logger.error({error: error.message, retryCount, maxReconnects: this.maxReconnects},
|
|
||||||
'WsRequestor:request - connection attempt failed');
|
|
||||||
|
|
||||||
if (retryCount <= this.maxReconnects &&
|
if (retryCount <= this.maxReconnects &&
|
||||||
this.retryPolicyValues?.length &&
|
this.retryPolicyValues?.length &&
|
||||||
this._shouldRetry(error, this.retryPolicyValues)) {
|
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;
|
const delay = this.backoffMs;
|
||||||
this.backoffMs = this.backoffMs < 2000 ? this.backoffMs * 2 : (this.backoffMs + 2000);
|
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));
|
await new Promise((resolve) => setTimeout(resolve, delay));
|
||||||
this.logger.error('WsRequestor:request - retry delay complete, attempting retry');
|
|
||||||
continue;
|
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;
|
throw lastError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -370,7 +361,7 @@ class WsRequestor extends BaseRequestor {
|
|||||||
|
|
||||||
this
|
this
|
||||||
.once('ready', (ws) => {
|
.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');
|
this.removeAllListeners('not-ready');
|
||||||
if (this.connections > 1) this.request('session:reconnect', this.url);
|
if (this.connections > 1) this.request('session:reconnect', this.url);
|
||||||
resolve();
|
resolve();
|
||||||
|
|||||||
Reference in New Issue
Block a user