toeverything/AFFiNE · error

Image failed to load:

Error message

Image failed to load:

What it means

Warning logged in `waitForImages` (used by printToPdf) for each image whose load failed — `img.complete` is true but `naturalWidth` is 0, meaning the src could not be loaded (broken URL, network error, or CORS). Printing continues without that image; it is a diagnostic, not an abort of the print flow.

Source

Thrown at blocksuite/affine/shared/src/utils/print-to-pdf.ts:269

          }
          if (
            root instanceof view.HTMLElement ||
            root instanceof view.ShadowRoot
          ) {
            root.childNodes.forEach(findImages);
          }
          if (root instanceof view.HTMLElement && root.shadowRoot) {
            findImages(root.shadowRoot);
          }
        };

        findImages(container);

        await Promise.all(
          images.map(img => {
            if (img.complete) {
              if (img.naturalWidth === 0) {
                console.warn('Image failed to load:', img.src);
              }
              return Promise.resolve();
            }
            return new Promise(resolve => {
              img.onload = resolve;
              img.onerror = resolve;
            });
          })
        );
      };

      await waitForImages(importedRoot);

      // browser may take some time to load font or other resources
      await (doc.fonts?.ready ??
        new Promise<void>(resolve => {
          setTimeout(() => {
            resolve();

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Check the image URL is reachable and CORS-enabled.
  2. Retry printing after the image loads.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Triggered during print-to-PDF when an image element has completed loading but naturalWidth is 0, indicating the image resource failed to load.

Common situations: Occurs when printing a page whose images are broken or unreachable, so they are missing from the PDF. Check the image URLs and network before printing.


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