fix: Micro-fixes: dead comment, timer null, AbortController, address guard, catch reset (#261)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
95955f23a3
commit
d1d943e5fd
3 changed files with 7 additions and 0 deletions
|
|
@ -362,12 +362,15 @@ const totalSupply = computed(() => {
|
|||
|
||||
async function fetchStats() {
|
||||
try {
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 10000);
|
||||
const endpoint = `${window.location.origin}/api/graphql`;
|
||||
const response = await fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
signal: controller.signal,
|
||||
body: JSON.stringify({
|
||||
query: `
|
||||
query ProtocolStats {
|
||||
|
|
@ -391,6 +394,7 @@ async function fetchStats() {
|
|||
}),
|
||||
});
|
||||
|
||||
clearTimeout(timeout);
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch stats');
|
||||
}
|
||||
|
|
@ -437,6 +441,7 @@ onMounted(async () => {
|
|||
// Escalate to error state if no data arrives within the timeout window
|
||||
loadingTimer = window.setTimeout(() => {
|
||||
if (!stats.value) error.value = true;
|
||||
loadingTimer = null;
|
||||
}, LOADING_TIMEOUT_MS);
|
||||
await fetchStats();
|
||||
fetchEthPrice();
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ async function fetchWalletData(addr: string) {
|
|||
stats.value = json?.data?.statss?.items?.[0] ?? null;
|
||||
} catch {
|
||||
holder.value = null;
|
||||
stats.value = null;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue