fix: set loaded=true after open() to prevent overlay manager crash on load#33
Merged
fix: set loaded=true after open() to prevent overlay manager crash on load#33
Conversation
… load Fixes #32 The `loaded` flag was set only after `pdfViewer.pagesPromise` resolved. During that window, post-open initialization (e.g. auto-print detection) can trigger `window.print()`, which calls `ensureOverlay()`. In certain environments this throws "The overlay manager has not yet been initialized." Since `loaded` was still false, the error handler replaced the viewer body and made every PDF appear to fail on load. Fix: move `loaded = true` to immediately after `open()` completes. The PDF is successfully opening at that point; errors during subsequent page rendering are non-fatal, consistent with the original intent of the flag. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
The
loadedflag was set only afterpdfViewer.pagesPromiseresolved. During that window, post-open initialization (e.g. auto-print detection) can triggerwindow.print(), which callsensureOverlay(). In certain environments this throws synchronously before the overlay manager is available. Sinceloadedwas stillfalse, the error handler replaced the viewer body and every PDF appeared to fail on load.Fix: move
loaded = trueto immediately afteropen()completes. The PDF is successfully opening at that point — errors during subsequent page rendering are non-fatal, consistent with the original intent of the flag (added in #30 to suppress the drag-text crash).Test plan
file.pdf#page=3) — verify it navigates to the correct page🤖 Generated with Claude Code