Repository navigation
fix(export): cancel PDF work when requesting document retires - #34907
Merged
Merged
Conversation
OrcaWin
force-pushed
the
OrcaWin/pdf-export-document-lifetime
branch
from
October 28, 2026 09:45
ffa4b8d to
12fd28f
Compare
OrcaWin
marked this pull request as ready for review
October 28, 2026 09:45
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 16 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
ELI5
A Markdown PDF export should stop when its requesting window document crashes or reloads, before it asks the user where to save. A file the user already chose to save still finishes writing.
What Changed
Bind the interactive export to the existing renderer-document lifetime and pass its AbortSignal into the converter. Retirement destroys the hidden renderer, removes its temporary document and listeners, suppresses late image/print continuations, and returns cancellation. Node receives the signal for best-effort initial-write cancellation; cleanup waits for that write to settle so a late-created file is still removed. Load-file and load-event rejections are observed together.
Captured exports continue through ordinary tab/file selection and same-document navigation. Concurrent requesters and a new document on the same surviving sender remain independent. Retirement while a save dialog is already open rejects its eventual selection before writing; a valid file write that already started finishes independently of later retirement. The existing print/security settings, exclusive temporary-file ownership, timeout and output bytes remain covered.
Why
A PDF export started from Markdown can outlive a crashed, reloaded, or replaced requesting document. The hidden export renderer and temporary HTML stay alive until conversion settles or its 60-second render timeout; a late conversion then opens a save dialog for an obsolete request. The export path was introduced by
3a58a829f94(#882).Linked Issue
Found during the authorized document-lifetime/resource audit; no pre-existing issue.
Visual Proof
Not captured. This draft changes obsolete native-dialog behavior, but no app/native window or save dialog was launched under the required background-launch policy. The production-seam before/after counts below are automated evidence; physical native-dialog and focus verification remains pending.
Testing
Validation:
7cdfebdc1becc12ae969bd34ea98186b7f3947ff: 19 new cases fail, 30 existing cases pass. Fixed focused run: 4 suites, 49 tests pass. Covers pending initial write, load-file/load-event, images and print; late resolution/rejection; replacement and overlapping requesters; stale save choice; accepted-write completion; and 10 alternating cycles (5 asserted successful saves with one print and the written PDF each, 5 retirements with no print, dialog or write) with no remaining listeners, timers or temporary documents.14ab7f0c5ec;ORCA_BACKGROUND_LAUNCH=1 pnpm check:changed --maxWorkers=2: all 20 checks pass (833.9s).No app or native save dialog was launched. Deterministic boundary counts establish production cleanup/admission and stale-result behavior; physical Electron print cancellation, native-dialog presentation, filesystem interruption timing, CPU/heap impact and native platform coverage remain unmeasured. An already-open save dialog stays under native ownership until it settles. This change adds no remote/mobile wire contract or workspace-path assumption.
Review
Self-reviewed lifetime boundaries, late promise handling, temporary-file ownership, successor/independent requesters and accepted-write completion. Coordinator owns independent review.
Agent skill upstream boundary
Notes
Uses existing platform-neutral renderer events, Node AbortSignal and path handling. Remote/mobile contracts, git worktrees and folder workspaces gain no assumptions. Native Linux/macOS/Windows verification remains pending.
Checklist