Skip to main content

NetworkController Events

13 events registered.

NameDeprecated
infuraIsBlocked
infuraIsUnblocked
networkAdded
networkDidChange
networkRemoved
networkWillChange
rpcEndpointChainAvailable
rpcEndpointChainDegraded
rpcEndpointChainUnavailable
rpcEndpointDegraded
rpcEndpointRetried
rpcEndpointUnavailable
stateChange

NetworkController:infuraIsBlocked​

Package: @metamask/network-controller

infuraIsBlocked is published after the network is switched to an Infura network, but when Infura returns an error blocking the user based on their location.

Payload signature:

[]

NetworkController:infuraIsUnblocked​

Package: @metamask/network-controller

infuraIsBlocked is published either after the network is switched to an Infura network and Infura does not return an error blocking the user based on their location, or the network is switched to a non-Infura network.

Payload signature:

[]

NetworkController:networkAdded​

Package: @metamask/network-controller

networkAdded is published after a network configuration is added to the network configuration registry and network clients are created for it.

Payload signature:

[networkConfiguration: NetworkConfiguration]

NetworkController:networkDidChange​

Package: @metamask/network-controller

networkDidChange is published after a provider has been created for a newly switched network (but before the network has been confirmed to be available).

Payload signature:

[NetworkState]

NetworkController:networkRemoved​

Package: @metamask/network-controller

networkRemoved is published after a network configuration is removed from the network configuration registry and once the network clients have been removed.

Payload signature:

[networkConfiguration: NetworkConfiguration]

NetworkController:networkWillChange​

Package: @metamask/network-controller

networkWillChange is published when the current network is about to be switched, but the new provider has not been created and no state changes have occurred yet.

Payload signature:

[NetworkState]

NetworkController:rpcEndpointChainAvailable​

Package: @metamask/network-controller

NetworkController:rpcEndpointChainAvailable is published in one of two cases:

  1. The first time that a 2xx request is made to any of the endpoints in an endpoint chain.
  2. When requests to any of the endpoints previously failed (placing the endpoint in a degraded or unavailable status), but are now succeeding again.

Payload signature:

[
{
chainId: Hex;
networkClientId: NetworkClientId;
}
]

NetworkController:rpcEndpointChainDegraded​

Package: @metamask/network-controller

NetworkController:rpcEndpointChainDegraded is published for any of the endpoints in an endpoint chain when one of the following two conditions hold (and the chain is not already in a degraded state):

  1. A successful (2xx) request, even after being retried, cannot be made to the endpoint.
  2. A successful (2xx) request can be made to the endpoint, but it takes longer than expected to complete.

Note that this event will be published even if there are local connectivity issues which prevent requests from being initiated. This is intentional.

Payload signature:

[
{
chainId: Hex;
duration?: number;
error: unknown;
networkClientId: NetworkClientId;
retryReason?: RetryReason;
rpcMethodName: string;
traceId?: string;
type: DegradedEventType;
}
]

NetworkController:rpcEndpointChainUnavailable​

Package: @metamask/network-controller

NetworkController:rpcEndpointChainUnavailable is published when, after trying all endpoints in an endpoint chain, the last failover reaches a maximum number of consecutive 5xx responses, breaking the underlying circuit.

In other words, this event will not be published if a failover is available, even if the primary is not.

Payload signature:

[
{
chainId: Hex;
error: unknown;
networkClientId: NetworkClientId;
}
]

NetworkController:rpcEndpointDegraded​

Package: @metamask/network-controller

NetworkController:rpcEndpointDegraded is published for any of the endpoints in an endpoint chain when:

  1. A successful (2xx) request, even after being retried, cannot be made to the endpoint.
  2. A successful (2xx) request can be made to the endpoint, but it takes longer than expected to complete.

Note that this event will be published even if there are local connectivity issues which prevent requests from being initiated. This is intentional.

Payload signature:

[
{
chainId: Hex;
duration?: number;
endpointUrl: string;
error: unknown;
networkClientId: NetworkClientId;
primaryEndpointUrl: string;
retryReason?: RetryReason;
rpcMethodName: string;
traceId?: string;
type: DegradedEventType;
}
]

NetworkController:rpcEndpointRetried​

Package: @metamask/network-controller

NetworkController:rpcEndpointRetried is published before a request to any endpoint in an endpoint chain is retried.

This is mainly useful for tests.

Payload signature:

[
{
attempt: number;
chainId: Hex;
endpointUrl: string;
networkClientId: NetworkClientId;
primaryEndpointUrl: string;
}
]

NetworkController:rpcEndpointUnavailable​

Package: @metamask/network-controller

NetworkController:rpcEndpointUnavailable is published when any endpoint in an endpoint chain reaches a maximum number of consecutive 5xx responses, breaking the underlying circuit.

In other words, this event will be published if a primary is not available, even if a failover is.

Payload signature:

[
{
chainId: Hex;
endpointUrl: string;
error: unknown;
networkClientId: NetworkClientId;
primaryEndpointUrl: string;
}
]

NetworkController:stateChange​

Package: @metamask/network-controller

Payload signature:

[NetworkState, Patch[]]