fix: address review — floor price null guard, fetch timeout (#171)

This commit is contained in:
openhands 2026-02-22 21:21:45 +00:00
parent c374e29817
commit ae44bddf7f

View file

@ -221,7 +221,12 @@ async function fetchEthPrice() {
const now = Date.now();
if (ethUsdPrice.value !== null && (now - ethPriceCacheTime) < ETH_PRICE_CACHE_MS) return;
try {
const resp = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd');
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 5000);
const resp = await fetch('https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd', {
signal: controller.signal,
});
clearTimeout(timeout);
if (!resp.ok) throw new Error('ETH price fetch failed');
const data = await resp.json();
if (data.ethereum?.usd) {
@ -359,7 +364,7 @@ const floorPriceAmount = computed(() => {
});
const floorPriceDisplay = computed(() => {
if (floorPriceAmount.value == null) return null;
if (floorPriceAmount.value == null) return '—';
const eth = floorPriceAmount.value;
if (ethUsdPrice.value) return formatUsd(eth * ethUsdPrice.value);
return formatSmallEth(eth);