toeverything/AFFiNE · error · Error
Document not opened
Error message
Document not opened
What it means
A document-availability guard inside the pdf.worker's docInfo$ pipeline: doc$ (a shared ReplaySubject of the opened PDF document) emitted a falsy value, meaning open() was never called with data or the document failed/closed before metadata extraction. It fires when metadata (page count/sizes) is requested before a document has been successfully opened in the worker backend.
Source
Thrown at packages/frontend/core/src/modules/pdf/renderer/pdf.worker.ts:71
observer.next(doc);
return () => {
setTimeout(() => {
doc.close();
}, 1000); // Waits for ObjectPool GC
};
});
}),
share({
connector: () => new ReplaySubject(1),
})
);
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);View on GitHub (pinned to b4c8548c09)
Solutions
- Open the document in the PDF worker before requesting pages.
- Re-initialize the renderer if the document was closed.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown in the PDF renderer worker when viewer.open returns no document for the provided binary, or when docInfo/render is requested while doc$ holds no opened document.
Common situations: Occurs when a PDF fails to open in the viewer, typically due to corrupted or unsupported PDF data. Re-upload a valid PDF file and try again.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/4723fc44d184abf8.
Report an issue: GitHub.