From 914c0fae0edd503cb49b2cddd45a78dae8bf95fa Mon Sep 17 00:00:00 2001 From: Ardis Lu Date: Wed, 7 Aug 2024 23:19:46 -0700 Subject: [PATCH] Fix page getting stuck on RPC error Now the page will swallow the error so the user can re-try the query. --- index.html | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index f358760..76e5adb 100644 --- a/index.html +++ b/index.html @@ -74,18 +74,17 @@ method: 'eth_getBlockByNumber', params: [`0x${BigInt(num).toString(16)}`, false] }) - }).then(r => r.json()); + }).then(r => r.json()).catch(e => e); const block = response?.result; - if (block === undefined) { - return; - } - const { header, rlp, hash } = calculate(block); + if (block !== undefined) { + const { header, rlp, hash } = calculate(block); - document.querySelector('#out-header').textContent = `[\n ${header.join(',\n ')}\n]`; - document.querySelector('#out-rlp').textContent = rlp; - document.querySelector('#out-hash').textContent = hash; - document.querySelector('output').style.setProperty('display', 'unset'); + document.querySelector('#out-header').textContent = `[\n ${header.join(',\n ')}\n]`; + document.querySelector('#out-rlp').textContent = rlp; + document.querySelector('#out-hash').textContent = hash; + document.querySelector('output').style.setProperty('display', 'unset'); + } e.target.removeAttribute('data-loading'); }); -- 2.47.3