fix: reset printToPDF queue after a rejection#51174
Open
codebytere wants to merge 1 commit intomainfrom
Open
Conversation
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.
e617e53 to
603d8a4
Compare
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.
Description of Change
Closes #51145
The module-scoped
pendingPromiseinwebContents.printToPDFwas chained with.then(onFulfilled)and never cleared. Once a call rejected (e.g. an out-of-rangepageRangeslike"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-
WebContentsWeakMapqueue that swallows prior rejections before chaining and clears its entry once the tail drains.Checklist
npm testpassesRelease Notes
Notes: Fixed
webContents.printToPDFrejecting on all subsequent calls after a prior call was rejected with an invalidpageRangesvalue.