Skip to content

fix(pdf): surface the underlying error when a PDF fails to load - #522

Merged
jsgrrchg merged 1 commit into
mainfrom
zeron/pdf-reader-compatibility-issue
Oct 8, 2026
Merged

jsgrrchg merged 1 commit into
mainfrom
zeron/pdf-reader-compatibility-issue

Conversation

@jsgrrchg

@jsgrrchg jsgrrchg commented Oct 8, 2026

Copy link
Copy Markdown
Owner

When a PDF fails to load, the viewer runs the raw error through classifyPdfError and only shows a friendly message. Anything that doesn't match its keywords becomes "An unexpected error occurred while loading this PDF.", and the original error is never logged. That is exactly what the reporter of #519 sees, and right now neither the user nor we can tell what actually failed.

This also hid one of our own messages: "This PDF can no longer be previewed because it is outside the active vault." has no matching keyword, so it was shown as the generic error too.

Changes:

  • The error view gains a Show Details toggle that reveals the raw pdf.js error (monospace, selectable) with a Copy button. The toggle only appears when the friendly message hides information.
  • Every failure is logged via logError("pdf", "Failed to load PDF", { path, error }), so it ends up in the renderer log even if the user never opens the details.
  • The "outside the active vault" message is now shown as-is.
  • The error view is extracted into PdfErrorView, and the duplicated button styles into PdfErrorButton.

This doesn't fix the root cause in #519; it's meant to capture the real error so we can diagnose it. For reference, the PDF attached to that issue loads and renders without errors locally with pdf.js 6.2.108 using the viewer's exact options (including stopAtErrors: true), both in Node and in headless Chrome, canvas and text layer included.

Related to #519.

Validation:

  • PdfTabView tests: 15 passed, including two new ones (details toggle and copy; outside-vault message without details).
  • tsc --noEmit -p tsconfig.app.json and eslint on the changed files passed.
  • Not exercised manually in the running app.

The PDF viewer collapsed most load and render failures into a generic
"An unexpected error occurred" message and never logged the original
error, so failures reported by users could not be diagnosed.

- Add a "Show Details" toggle to the error view that reveals the raw
  pdf.js error with a Copy button.
- Log every failure through logError("pdf", ...) so it lands in the
  renderer log.
- Show the "outside the active vault" message as-is instead of letting
  the classifier turn it into the generic message.
@jsgrrchg
jsgrrchg merged commit a4dba81 into main Oct 8, 2026
9 checks passed
@jsgrrchg
jsgrrchg deleted the zeron/pdf-reader-compatibility-issue branch October 8, 2026 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant