ellite/Wallos · error · Error

HTTP

Error message

HTTP ${response.status}

What it means

This shared helper (used for fetching source data, e.g. from Brave and similar providers) throws a raw `HTTP ${response.status}` Error when response.ok is false. Unlike the settings errors, no localization and no response body are included — the consumer gets only the numeric status, e.g. 'HTTP 429' or 'HTTP 403'.

Solutions

  1. Read the thrown status: 429 means back off and slow the polling interval; 401/403 means fix the API key/credentials.
  2. Rely on the built-in retry path (the helper retries on failure) but back off longer when the status is 429 and honor Retry-After headers.
  3. Verify the source URL and identifier are correct when the status is 404.
  4. Wrap the call to catch this error and show a provider-specific message to the user instead of the raw status.

Example fix

// before
if (!response.ok) {
  throw new Error(`HTTP ${response.status}`);
}
// after
if (!response.ok) {
  const retryAfter = response.headers.get('Retry-After');
  throw new Error(`HTTP ${response.status}${retryAfter ? ` (retry after ${retryAfter}s)` : ''}`);
}
Defensive patterns

Strategy: retry

Validate before calling

function isValidSourceUrl(url) {
  try { const u = new URL(url); return u.protocol === 'https:' || u.protocol === 'http:'; } catch { return false; }
}

Try / catch

fetchSourceData(url).catch(err => {
  const m = /^HTTP (\d+)$/.exec(err.message);
  if (m && m[1] === '429') {
    return scheduleRetryWithBackoff(url); // honor rate limit
  }
  if (m && (m[1] === '401' || m[1] === '403')) {
    showProviderKeyError();
  } else {
    showGenericSourceError(err);
  }
});

Prevention

When it happens

Trigger: The upstream source API responds with any non-2xx status: 429 when the provider rate-limits (the code comments on Brave doing this), 401/403 when the API key is missing or invalid, 404 for a wrong source URL, or 5xx provider outages.

Common situations: Aggressive polling of a rate-limited provider (429); expired or unconfigured API keys (401/403); provider downtime returning 502/503; mistyped source identifiers producing 404.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of ellite/Wallos@52820e87ca (2026-09-13). Data as JSON: /api/errors/9eeea85484f611a4. Report an issue: GitHub.

Appendix: source

Thrown at scripts/subscriptions.js:455

        } else {
          showSearchState(resultsContainer, 'empty');
        }
      })
      .catch(error => {
        console.error(translate('error_fetching_image_results'), source.label, error);
        showSearchState(resultsContainer, 'error');
      });
  });
}

function fetchLogoSearchSource(url, retry = true) {
  return fetch(url, {
    cache: "no-store",
    headers: { "Accept": "application/json" },
  })
    .then(response => {
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}`);
      }
      return response.text();
    })
    .then(body => {
      try {
        return JSON.parse(body);
      } catch (error) {
        throw new Error("Invalid JSON response");
      }
    })
    .catch(error => {
      if (retry) {
        // Wait a moment before retrying: sources like Brave rate-limit
        // aggressively, and retrying instantly just repeats the failure.
        return new Promise(resolve => setTimeout(resolve, 600))
          .then(() => fetchLogoSearchSource(url, false));
      }
      throw error;

View on GitHub (pinned to 52820e87ca)