GoogleChrome/lighthouse · error · Error

${resp.status} fetching gist

Error message

${resp.status} fetching gist

What it means

Thrown by GithubApi.getGistFileContentAsJson when the GET /gists/:id response is not OK and not one of the specially handled statuses (304 not-modified served from cache, 404 which deletes the IDB entry, 401 which signs out). Any other failure status (e.g. 403 rate limit, 5xx) reaches this throw with the HTTP status embedded in the message.

Source

Thrown at viewer/app/src/github-api.js:131

          const remaining = Number(resp.headers.get('X-RateLimit-Remaining'));
          const limit = Number(resp.headers.get('X-RateLimit-Limit'));
          if (remaining < 10) {
            logger.warn('Approaching GitHub\'s rate limit. ' +
                        `${limit - remaining}/${limit} requests used. Consider signing ` +
                        'in to increase this limit.');
          }

          if (!resp.ok) {
            // Should only be 304 if cachedGist exists and etag was sent, but double check.
            if (resp.status === 304 && cachedGist) {
              return Promise.resolve(cachedGist);
            } else if (resp.status === 404) {
              // Delete the entry from IDB if it no longer exists on the server.
              idbKeyval.delete(id); // Note: async.
            } else if (resp.status === 401 && accessToken) {
              this._auth.signOut();
            }
            throw new Error(`${resp.status} fetching gist`);
          }

          const etag = resp.headers.get('ETag');
          return resp.json().then(json => {
            const gistFiles = Object.keys(json.files);
            // Attempt to use first file in gist with report extension.
            let filename = gistFiles.find(filename => filename.endsWith(GithubApi.LH_JSON_EXT));
            // Otherwise, fall back to first json file in gist
            if (!filename) {
              filename = gistFiles.find(filename => filename.endsWith('.json'));
            }
            if (!filename) {
              throw new Error(
                `Failed to find a Lighthouse report (*${GithubApi.LH_JSON_EXT}) in gist ${id}`
              );
            }
            const f = json.files[filename];
            if (f.truncated) {

View on GitHub (pinned to 9515cd4e58)

Solutions

  1. Sign in to obtain an access token (raises the rate limit and avoids 403) — the viewer wires this via FirebaseAuth.
  2. On 403/rate-limit, back off and retry after the reset window; surface the X-RateLimit headers (the code already warns near the limit).
  3. Handle 404 by telling the user the gist no longer exists; handle 5xx with a retry.

Example fix

// before
const lhr = await githubApi.getGistFileContentAsJson(id);

// after
try {
  const lhr = await githubApi.getGistFileContentAsJson(id);
} catch (err) {
  const status = Number(err.message.match(/^(\d+)/)?.[1]);
  if (status === 403) showMessage('GitHub rate limit reached — sign in or try later.');
  else if (status === 404) showMessage('This gist no longer exists.');
  else showMessage(`Could not load gist: ${err.message}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Cannot fully prevent (server-side failures), but reduce 403s by authenticating.
if (!(await auth.getAccessTokenIfLoggedIn())) {
  warn('Not signed in — anonymous GitHub rate limit applies (60 req/hour).');
}

Try / catch

try {
  const lhr = await githubApi.getGistFileContentAsJson(id);
} catch (err) {
  const status = Number(err.message.match(/^(\d+)/)?.[1]);
  if (status === 403) showMessage('GitHub rate limit — sign in or retry later.');
  else if (status === 404) showMessage('Gist not found.');
  else if (status >= 500) retry();
  else throw err;
}

Prevention

When it happens

Trigger: Fetching a gist returns a non-OK status other than 304/404/401 — most commonly 403 (rate limited or forbidden) or 500/502/503 server errors.

Common situations: Unauthenticated use hitting GitHub's low anonymous rate limit (60 req/hour); token revoked/invalid producing 403; GitHub incident returning 5xx; network proxy returning unexpected codes.

Related errors


AI-assisted analysis of GoogleChrome/lighthouse@9515cd4e58 (2026-08-13). Data as JSON: /api/errors/1b74e4fda1b3b2f5. Report an issue: GitHub.