Skip to content

Commit

Permalink
feat: add more RPC events
Browse files Browse the repository at this point in the history
  • Loading branch information
infloop committed Aug 28, 2024
1 parent fb6e10b commit 2d7fd4a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/execution/src/events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,4 +58,5 @@ export type ProviderEvents =
export type FallbackProviderEvents =
| ProviderEvents
| FallbackProviderRequestEvent
| FallbackProviderRequestNonRetryableErrorEvent
| FallbackProviderRequestFailedAllEvent;
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
FallbackProviderEvents,
FallbackProviderRequestEvent,
FallbackProviderRequestFailedAllEvent,
FallbackProviderRequestNonRetryableErrorEvent,
} from '../events';

/**
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 2d7fd4a

Please sign in to comment.