Skip to content

fix: set loaded=true after open() to prevent overlay manager crash on load#33

Merged
jrandolf merged 2 commits intomainfrom
fix/overlay-manager-crash
Mar 11, 2026
Merged

fix: set loaded=true after open() to prevent overlay manager crash on load#33
jrandolf merged 2 commits intomainfrom
fix/overlay-manager-crash

Conversation

@jrandolf
Copy link
Contributor

Summary

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 synchronously before the overlay manager is available. Since loaded was still false, the error handler replaced the viewer body and every PDF appeared 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 (added in #30 to suppress the drag-text crash).

Test plan

  • Open any PDF — verify it loads without the overlay manager error
  • Drag text in a loaded PDF — verify the viewer stays intact (regression from feat: zoom, sidebar, Ctrl+P, drag crash #30)
  • Open a PDF with a URL hash (file.pdf#page=3) — verify it navigates to the correct page

🤖 Generated with Claude Code

jrandolf and others added 2 commits March 11, 2026 12:41
… 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>
@jrandolf jrandolf enabled auto-merge (squash) March 11, 2026 20:00
@jrandolf jrandolf merged commit bb0f4d5 into main Mar 11, 2026
1 check passed
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.

[Bug Report] PDF fails to open in v0.1.8

1 participant