@lido-nestjs/execution 1.21.0 → 1.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ export interface SimpleFallbackProviderConfig {
11
11
  minBackoffMs?: number;
12
12
  maxBackoffMs?: number;
13
13
  logRetries?: boolean;
14
+ logSuccessfulAttempts?: boolean;
14
15
  resetIntervalMs?: number;
15
16
  fetchMiddlewares?: MiddlewareCallback<Promise<any>>[];
16
17
  maxTimeWithoutNewBlocksMs?: number;
@@ -30,7 +30,7 @@ exports.SimpleFallbackJsonRpcBatchProvider = class SimpleFallbackJsonRpcBatchPro
30
30
  this._childRpcListenersAttached = false;
31
31
  this._eventEmitter = new lazyEventEmitter.LazyEventEmitter();
32
32
  this._setupLazyChildListeners();
33
- this.config = Object.assign({ maxRetries: 3, minBackoffMs: 500, maxBackoffMs: 5000, logRetries: true, resetIntervalMs: 10000, maxTimeWithoutNewBlocksMs: 60000 }, config);
33
+ this.config = Object.assign({ maxRetries: 3, minBackoffMs: 500, maxBackoffMs: 5000, logRetries: true, logSuccessfulAttempts: true, resetIntervalMs: 10000, maxTimeWithoutNewBlocksMs: 60000 }, config);
34
34
  this.logger = logger;
35
35
  const conns = config.urls.filter((url) => {
36
36
  if (!url) {
@@ -165,7 +165,9 @@ exports.SimpleFallbackJsonRpcBatchProvider = class SimpleFallbackJsonRpcBatchPro
165
165
  let performRetryAttempt = 0;
166
166
  attempt++;
167
167
  // Log which provider we're attempting to use
168
- this.logger.log(this.formatLog(`Attempting ${method} (attempt ${attempt}/${this.fallbackProviders.length})`, this.activeFallbackProviderIndex));
168
+ if (this.config.logSuccessfulAttempts) {
169
+ this.logger.log(this.formatLog(`Attempting ${method} (attempt ${attempt}/${this.fallbackProviders.length})`, this.activeFallbackProviderIndex));
170
+ }
169
171
  // awaiting is extremely important here
170
172
  // without it, the error will not be caught in current try-catch scope
171
173
  const result = await retry(() => {
@@ -182,7 +184,9 @@ exports.SimpleFallbackJsonRpcBatchProvider = class SimpleFallbackJsonRpcBatchPro
182
184
  return provider.provider.perform(method, params);
183
185
  });
184
186
  // Log successful request
185
- this.logger.log(this.formatLog(`${method} successful after ${performRetryAttempt} retry attempt(s)`, this.activeFallbackProviderIndex));
187
+ if (this.config.logSuccessfulAttempts) {
188
+ this.logger.log(this.formatLog(`${method} successful after ${performRetryAttempt} retry attempt(s)`, this.activeFallbackProviderIndex));
189
+ }
186
190
  return result;
187
191
  }
188
192
  catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lido-nestjs/execution",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "MIT",