Skip to content

Improve error handling in the PDFFindController.prototype.#extractText method#21197

Merged
calixteman merged 2 commits into
mozilla:masterfrom
Snuffleupagus:find-#extractText-more-await
Apr 30, 2026
Merged

Improve error handling in the PDFFindController.prototype.#extractText method#21197
calixteman merged 2 commits into
mozilla:masterfrom
Snuffleupagus:find-#extractText-more-await

Conversation

@Snuffleupagus
Copy link
Copy Markdown
Collaborator

  • Improve error handling in the PDFFindController.prototype.#extractText method

    This handles all errors correctly, if e.g. the document is closed in the middle of searching.
    Also, replacing the "promise chains" with more await helps simplify the code a little bit.

  • Avoid setting page-content for a previous document in the PDFFindController.prototype.#extractText method

    Given that all of the relevant API methods are asynchronous it's possible, although quite unlikely, that the existing "is the document active" check won't catch all situations where the document was closed in the middle of searching.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 61.11111% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.89%. Comparing base (34c3ee1) to head (aa08b02).

Files with missing lines Patch % Lines
web/pdf_find_controller.js 61.11% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21197      +/-   ##
==========================================
- Coverage   55.94%   55.89%   -0.06%     
==========================================
  Files         218      218              
  Lines       59062    59066       +4     
==========================================
- Hits        33043    33014      -29     
- Misses      26019    26052      +33     
Flag Coverage Δ
fonttest ?
unittest 55.05% <61.11%> (+<0.01%) ⬆️
unittestcli 55.71% <61.11%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…xt` method

This handles *all* errors correctly, if e.g. the document is closed in the middle of searching.
Also, replacing the "promise chains" with more `await` helps simplify the code a little bit.
…troller.prototype.#extractText` method

Given that all of the relevant API methods are asynchronous it's possible, although quite unlikely, that the existing "is the document active" check won't catch all situations where the document was closed in the middle of searching.
Copy link
Copy Markdown
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

@calixteman calixteman merged commit ac63d85 into mozilla:master Apr 30, 2026
24 of 30 checks passed
@Snuffleupagus Snuffleupagus deleted the find-#extractText-more-await branch April 30, 2026 09:14
@timvandermeij
Copy link
Copy Markdown
Contributor

Thank you for helping out with this!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants