toeverything/AFFiNE · error · Error

Page not found

Error message

Page not found

What it means

In the PDF worker's docInfo$ loop, thrown when doc.page(i) returns null for an index below pageCount, meaning the underlying PDF document reports a page count but cannot supply that page — a corrupted or inconsistent document.

Source

Thrown at packages/frontend/core/src/modules/pdf/renderer/pdf.worker.ts:83

    })
  );

  private readonly docInfo$: Observable<PDFMeta> = this.doc$.pipe(
    map(doc => {
      if (!doc) {
        throw new Error('Document not opened');
      }

      const pageCount = doc.pageCount();
      const pageSizes = [];
      let i = 0;
      let maxWidth = 0;
      let maxHeight = 0;

      for (; i < pageCount; i++) {
        const page = doc.page(i);
        if (!page) {
          throw new Error('Page not found');
        }
        const size = page.size();
        const width = Math.ceil(size.width);
        const height = Math.ceil(size.height);

        maxWidth = Math.max(maxWidth, width);
        maxHeight = Math.max(maxHeight, height);

        pageSizes.push({ width, height });
        page.close();
      }

      return {
        pageCount,
        pageSizes,
        maxSize: { width: maxWidth, height: maxHeight },
      };
    })

View on GitHub (pinned to b4c8548c09)

Solutions

  1. Request a page number within the document's page range.
  2. Refresh the page count after loading the document.
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown while collecting document metadata in the PDF worker when doc.page(i) returns null for an index below the reported pageCount.

Common situations: Triggered by a malformed PDF whose pages cannot all be accessed during loading. Re-export or repair the PDF and upload it again.


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