Skip to content

fix: reset printToPDF queue after a rejection#51221

Merged
codebytere merged 1 commit into
41-x-yfrom
trop/41-x-y-bp-fix-reset-printtopdf-queue-after-a-rejection-1776796571475
Apr 22, 2026
Merged

fix: reset printToPDF queue after a rejection#51221
codebytere merged 1 commit into
41-x-yfrom
trop/41-x-y-bp-fix-reset-printtopdf-queue-after-a-rejection-1776796571475

Conversation

@trop
Copy link
Copy Markdown
Contributor

@trop trop Bot commented Apr 21, 2026

Backport of #51174

See that PR for details.

Notes: Fixed webContents.printToPDF rejecting on all subsequent calls after a prior call was rejected with an invalid pageRanges value.

The module-scoped `pendingPromise` in `webContents.printToPDF` was chained
with `.then(onFulfilled)` and never cleared. Once a call rejected (e.g.
an out-of-range `pageRanges` like `"999"`), subsequent calls chained onto
the rejected promise and short-circuited without ever invoking
`_printToPDF` — so every following call re-surfaced the original error.

Replace the shared variable with a per-`WebContents` `WeakMap` queue that
swallows prior rejections before chaining and clears its entry once the
tail drains.

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
@trop trop Bot requested review from a team and codebytere April 21, 2026 18:36
@trop trop Bot added 41-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Apr 21, 2026
@codebytere codebytere merged commit 35aea3a into 41-x-y Apr 22, 2026
113 of 117 checks passed
@codebytere codebytere deleted the trop/41-x-y-bp-fix-reset-printtopdf-queue-after-a-rejection-1776796571475 branch April 22, 2026 10:32
@release-clerk
Copy link
Copy Markdown

release-clerk Bot commented Apr 22, 2026

Release Notes Persisted

Fixed webContents.printToPDF rejecting on all subsequent calls after a prior call was rejected with an invalid pageRanges value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

41-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant