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:
openhands 2026-02-25 07:24:48 +00:00
parent 95955f23a3
commit d1d943e5fd
3 changed files with 7 additions and 0 deletions

View file

@ -362,12 +362,15 @@ const totalSupply = computed(() => {
async function fetchStats() { async function fetchStats() {
try { try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 10000);
const endpoint = `${window.location.origin}/api/graphql`; const endpoint = `${window.location.origin}/api/graphql`;
const response = await fetch(endpoint, { const response = await fetch(endpoint, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
signal: controller.signal,
body: JSON.stringify({ body: JSON.stringify({
query: ` query: `
query ProtocolStats { query ProtocolStats {
@ -391,6 +394,7 @@ async function fetchStats() {
}), }),
}); });
clearTimeout(timeout);
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to fetch stats'); 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 // Escalate to error state if no data arrives within the timeout window
loadingTimer = window.setTimeout(() => { loadingTimer = window.setTimeout(() => {
if (!stats.value) error.value = true; if (!stats.value) error.value = true;
loadingTimer = null;
}, LOADING_TIMEOUT_MS); }, LOADING_TIMEOUT_MS);
await fetchStats(); await fetchStats();
fetchEthPrice(); fetchEthPrice();

View file

@ -40,6 +40,7 @@ async function fetchWalletData(addr: string) {
stats.value = json?.data?.statss?.items?.[0] ?? null; stats.value = json?.data?.statss?.items?.[0] ?? null;
} catch { } catch {
holder.value = null; holder.value = null;
stats.value = null;
} finally { } finally {
loading.value = false; loading.value = false;
} }

View file

@ -189,6 +189,7 @@ export async function loadActivePositions(chainId: number, endpointOverride?: st
// since GraphQL returns them as numeric strings // since GraphQL returns them as numeric strings
export async function loadMyClosedPositions(chainId: number, endpointOverride: string | undefined, account: GetAccountReturnType) { export async function loadMyClosedPositions(chainId: number, endpointOverride: string | undefined, account: GetAccountReturnType) {
if (!account.address) return [];
const targetEndpoint = resolveGraphqlEndpoint(chainId, endpointOverride); const targetEndpoint = resolveGraphqlEndpoint(chainId, endpointOverride);
logger.info(`loadMyClosedPositions for chainId: ${chainId}`); logger.info(`loadMyClosedPositions for chainId: ${chainId}`);
const res = await axios.post( const res = await axios.post(