Skip to content

Commit 716218f

Browse files
committed
Reduce default circuit break duration to 2 minutes
The `createServicePolicy` utility sets the default "circuit break duration" to 30 minutes. When used to hit an API, this signifies the amount of time requests to that API that will be paused if it consistently responds with enough 500s. Since the `createServicePolicy` utility is used to make network requests, however, it also signifies the amount of time that users will be "locked out" from interacting with a blockchain until requests respond successfully. Pausing for 30 minutes makes sense if an RPC endpoint is truly down, but it creates a major inconvenience if the endpoint mostly works and only certain kinds of requests fail. To address this, this commit reduces the default circuit break duration to 2 minutes to allow for faster recovery.
1 parent b9d7622 commit 716218f

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

packages/controller-utils/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add convenience variables for calculating the number of milliseconds in a higher unit of time
13+
- `SECOND` / `SECONDS`
14+
- `MINUTE` / `MINUTE`
15+
- `HOUR` / `HOURS`
16+
- `DAY` / `DAYS`
17+
18+
### Changed
19+
20+
- Update `createServicePolicy` to reduce circuit break duration from 30 minutes to 2 minutes
21+
- When hitting an API, this reduces the default duration for which requests to the API are paused when perceived to be unavailable
22+
1023
## [11.10.0]
1124

1225
### Added

packages/controller-utils/src/constants.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,43 @@ export const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<
195195
[ChainId['linea-mainnet']]: BuiltInNetworkName.LineaMainnet,
196196
[ChainId.aurora]: BuiltInNetworkName.Aurora,
197197
};
198+
199+
/**
200+
* The number of milliseconds in a second.
201+
*/
202+
export const SECOND = 1000;
203+
204+
/**
205+
* The number of milliseconds in a second.
206+
*/
207+
export const SECONDS = 1000;
208+
209+
/**
210+
* The number of milliseconds in a minute.
211+
*/
212+
export const MINUTE = SECONDS * 60;
213+
214+
/**
215+
* The number of milliseconds in a minute.
216+
*/
217+
export const MINUTES = SECONDS * 60;
218+
219+
/**
220+
* The number of milliseconds in a hour.
221+
*/
222+
export const HOUR = MINUTES * 60;
223+
224+
/**
225+
* The number of milliseconds in a hour.
226+
*/
227+
export const HOURS = MINUTES * 60;
228+
229+
/**
230+
* The number of milliseconds in a day.
231+
*/
232+
export const DAY = HOURS * 24;
233+
234+
/**
235+
* The number of milliseconds in a day.
236+
*/
237+
export const DAYS = HOURS * 24;

packages/controller-utils/src/index.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,42 @@ export type {
1616
CreateServicePolicyOptions,
1717
ServicePolicy,
1818
} from './create-service-policy';
19-
export * from './constants';
19+
export {
20+
RPC,
21+
FALL_BACK_VS_CURRENCY,
22+
IPFS_DEFAULT_GATEWAY_URL,
23+
GANACHE_CHAIN_ID,
24+
MAX_SAFE_CHAIN_ID,
25+
ERC721,
26+
ERC1155,
27+
ERC20,
28+
ERC721_INTERFACE_ID,
29+
ERC721_METADATA_INTERFACE_ID,
30+
ERC721_ENUMERABLE_INTERFACE_ID,
31+
ERC1155_INTERFACE_ID,
32+
ERC1155_METADATA_URI_INTERFACE_ID,
33+
ERC1155_TOKEN_RECEIVER_INTERFACE_ID,
34+
GWEI,
35+
ASSET_TYPES,
36+
TESTNET_TICKER_SYMBOLS,
37+
BUILT_IN_CUSTOM_NETWORKS_RPC,
38+
BUILT_IN_NETWORKS,
39+
OPENSEA_PROXY_URL,
40+
NFT_API_BASE_URL,
41+
NFT_API_VERSION,
42+
NFT_API_TIMEOUT,
43+
ORIGIN_METAMASK,
44+
ApprovalType,
45+
CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP,
46+
SECOND,
47+
SECONDS,
48+
MINUTE,
49+
MINUTES,
50+
HOUR,
51+
HOURS,
52+
DAY,
53+
DAYS,
54+
} from './constants';
2055
export type { NonEmptyArray } from './util';
2156
export {
2257
BNToHex,

0 commit comments

Comments
 (0)