koala73/worldmonitor · error · Error

HTTP ${resp.status}

Error message

HTTP ${resp.status}

What it means

Generic non-OK marker thrown by GoldIntelligencePanel.fetchData() when the plain fetch to /api/market/v1/get-gold-intelligence returns a non-2xx status. The panel's catch renders an error state with a retry hook, so the number after 'HTTP ' is the Edge endpoint's status. Note this call uses plain fetch (no premiumFetch/Bearer), so auth-related 401/403 here means the endpoint itself rejected, not missing Pro headers.

Source

Thrown at src/components/GoldIntelligencePanel.ts:161

  return `<div style="flex:1;text-align:center;padding:4px;background:rgba(255,255,255,0.03);border-radius:4px">
    <div style="font-size:calc(9px * var(--wm-panel-effective-scale, 1));color:var(--text-dim)">${escapeHtml(label)}</div>
    <div style="font-size:calc(11px * var(--wm-panel-effective-scale, 1));font-weight:600;color:${color}">${escapeHtml(fmtPct(pct, 1))}</div>
  </div>`;
}

export class GoldIntelligencePanel extends Panel {
  private _hasData = false;

  constructor() {
    super({ id: 'gold-intelligence', title: t('panels.goldIntelligence'), infoTooltip: t('components.goldIntelligence.infoTooltip') });
  }

  public async fetchData(): Promise<boolean> {
    this.showLoading();
    try {
      const url = toApiUrl('/api/market/v1/get-gold-intelligence');
      const resp = await fetch(url);
      if (!resp.ok) throw new Error(`HTTP ${resp.status}`);
      const data: GoldIntelligenceData = await resp.json();

      if (data.unavailable) {
        if (!this._hasData) this.showError('Gold data unavailable', () => void this.fetchData());
        return false;
      }

      if (!this.element?.isConnected) return false;
      this._hasData = true;
      this.render(data);
      return true;
    } catch (e) {
      if (this.isAbortError(e)) return false;
      if (!this.element?.isConnected) return false;
      if (!this._hasData) this.showError(e instanceof Error ? e.message : 'Failed to load', () => void this.fetchData());
      return false;
    }
  }

View on GitHub (pinned to eeab0a219f)

Solutions

  1. Open the network tab, confirm the exact status, and match it: 404 = endpoint missing (deploy functions / fix toApiUrl base), 5xx = upstream data source issue, 429 = rate limit
  2. Retry via the panel's built-in retry (showError('Gold data unavailable', ...) wires a re-fetch button) after the underlying issue clears
  3. If it persists, hit /api/market/v1/get-gold-intelligence directly in the browser to see the endpoint's own error body, and check the deployment includes api/market/v1/

Example fix

// before
const resp = await fetch(url);
if (!resp.ok) throw new Error(`HTTP ${resp.status}`); // 'HTTP 503' with no context

// after (surface the endpoint's own error body when present):
const resp = await fetch(url);
if (!resp.ok) {
  const detail = await resp.text().catch(() => '');
  throw new Error(`HTTP ${resp.status}${detail ? `: ${detail.slice(0, 200)}` : ''}`);
}
Defensive patterns

Strategy: retry

Validate before calling

const url = toApiUrl('/api/market/v1/get-gold-intelligence');
// probe deploy shape in dev before rendering the panel:
const head = await fetch(url, { method: 'HEAD' }).catch(() => null);
if (head && head.status === 404) console.warn('gold endpoint not deployed on this origin');

Try / catch

catch (e) { if (e instanceof Error && /^HTTP \d+$/.test(e.message)) { const status = Number(e.message.slice(5)); if (status === 429 || status >= 500) scheduleRetry(backoffMs); else showError(e.message); } else throw e; }

Prevention

When it happens

Trigger: GET /api/market/v1/get-gold-intelligence returning 404 (function not deployed or wrong base path in local dev), 500/502/503 (upstream gold data source failing), 429 (rate limited), or a 401/403 from an access rule on the deployment.

Common situations: Running the Vite dev server without the Edge functions emulated, so /api/* 404s; the upstream market data provider outage or key quota exhausted surfacing as 5xx; deploying the frontend without the api/ functions; a CDN/WAF rule blocking the path.

Related errors


AI-assisted analysis of koala73/worldmonitor@eeab0a219f (2026-08-21). Data as JSON: /api/errors/33aa7150e520feee. Report an issue: GitHub.