From 2d7fd4a604fda33a6605a98e378a0f36d41a1b41 Mon Sep 17 00:00:00 2001 From: infloop Date: Wed, 28 Aug 2024 20:34:48 +0300 Subject: [PATCH] feat: add more RPC events --- packages/execution/src/events/index.ts | 7 +++++++ .../provider/simple-fallback-json-rpc-batch-provider.ts | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/packages/execution/src/events/index.ts b/packages/execution/src/events/index.ts index 505c1d9..ca57263 100644 --- a/packages/execution/src/events/index.ts +++ b/packages/execution/src/events/index.ts @@ -12,6 +12,12 @@ export type FallbackProviderRequestFailedAllEvent = { error: AllProvidersFailedError; }; +export type FallbackProviderRequestNonRetryableErrorEvent = { + action: 'fallback-provider:request:non-retryable-error'; + provider: SimpleFallbackJsonRpcBatchProvider; + error: Error | unknown; +}; + export type FallbackProviderRequestEvent = { action: 'fallback-provider:request'; provider: SimpleFallbackJsonRpcBatchProvider; @@ -52,4 +58,5 @@ export type ProviderEvents = export type FallbackProviderEvents = | ProviderEvents | FallbackProviderRequestEvent + | FallbackProviderRequestNonRetryableErrorEvent | FallbackProviderRequestFailedAllEvent; diff --git a/packages/execution/src/provider/simple-fallback-json-rpc-batch-provider.ts b/packages/execution/src/provider/simple-fallback-json-rpc-batch-provider.ts index 56eb4b3..12538a7 100644 --- a/packages/execution/src/provider/simple-fallback-json-rpc-batch-provider.ts +++ b/packages/execution/src/provider/simple-fallback-json-rpc-batch-provider.ts @@ -32,6 +32,7 @@ import { FallbackProviderEvents, FallbackProviderRequestEvent, FallbackProviderRequestFailedAllEvent, + FallbackProviderRequestNonRetryableErrorEvent, } from '../events'; /** @@ -298,6 +299,12 @@ export class SimpleFallbackJsonRpcBatchProvider extends BaseProvider { // checking that error should not be retried on another provider if (this.isNonRetryableError(e)) { + const event: FallbackProviderRequestNonRetryableErrorEvent = { + action: 'fallback-provider:request:non-retryable-error', + provider: this, + error: e, + }; + this._eventEmitter.emit('rpc', event); throw e; }