Repository navigation
fix(pdf): surface the underlying error when a PDF fails to load - #522
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a PDF fails to load, the viewer runs the raw error through
classifyPdfErrorand 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:
logError("pdf", "Failed to load PDF", { path, error }), so it ends up in the renderer log even if the user never opens the details.PdfErrorView, and the duplicated button styles intoPdfErrorButton.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:
PdfTabViewtests: 15 passed, including two new ones (details toggle and copy; outside-vault message without details).tsc --noEmit -p tsconfig.app.jsonandeslinton the changed files passed.