toeverything/AFFiNE · error

Error fetching image:

Error message

Error fetching image:

What it means

Warning logged in `fetchImage` when both fetch attempts fail: the proxied fetch returned a non-ok response (or threw) and the direct fallback fetch also threw (network error, CORS, invalid URL). Returns null so callers get no image; this is an expected degradation for unreachable or blocked image sources, not a crash.

Source

Thrown at blocksuite/affine/shared/src/adapters/utils/fetch.ts:24

    if (url.startsWith('blob:')) {
      return await fetch(url, init);
    }
    if (url.startsWith('data:')) {
      return await fetch(url, init);
    }
    if (url.startsWith(window.location.origin)) {
      return await fetch(url, init);
    }
    return await fetch(proxy + '?url=' + encodeURIComponent(url), init)
      .then(res => {
        if (!res.ok) {
          throw new Error('Network response was not ok');
        }
        return res;
      })
      .catch(() => fetch(url, init));
  } catch (error) {
    console.warn('Error fetching image:', error);
    return null;
  }
};

const fetchable = (url: string) =>
  url.startsWith('http:') ||
  url.startsWith('https:') ||
  url.startsWith('data:');

export const FetchUtils = {
  fetchImage,
  fetchable,
};

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Check the image URL and network; retry the fetch.
  2. Use a CORS-accessible image source.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Triggered when fetchImageProxy fails to retrieve an image URL, even after falling back from the same-origin proxy to a direct fetch, returning null to the caller.

Common situations: Occurs when embedding or converting content whose remote images are unreachable, offline, or blocked by CORS. The image is omitted; check the URL and network connectivity.


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/6452be36730be44b. Report an issue: GitHub.