We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4a7f068 commit 81cddecCopy full SHA for 81cddec
1 file changed
src/util/ethereum/get-block.js
@@ -12,7 +12,18 @@ const getBlock = async blockHash => {
12
}
13
14
const web3Wrapper = web3.getWrapper();
15
- const block = await web3Wrapper.getBlockIfExistsAsync(blockHash);
+
16
+ const timeout = new Promise((resolve, reject) => {
17
+ const id = setTimeout(() => {
18
+ clearTimeout(id);
19
+ reject(new Error(`Fetching block ${blockHash} timed out after 10s`));
20
+ }, 10000);
21
+ });
22
23
+ const block = await Promise.race([
24
+ web3Wrapper.getBlockIfExistsAsync(blockHash),
25
+ timeout,
26
+ ]);
27
28
if (block === undefined) {
29
return null;
0 commit comments