Skip to content

Reject range requests made after ChunkedStreamManager.abort - #22052

Closed
charan-rathore wants to merge 1 commit into
mozilla:masterfrom
charan-rathore:fix/destroy-hang-after-abort
Closed

charan-rathore wants to merge 1 commit into
mozilla:masterfrom
charan-rathore:fix/destroy-hang-after-abort

Conversation

@charan-rathore

Copy link
Copy Markdown

Fixes #22051

PDFDocumentLoadingTask.destroy() never resolved when it was called while a page was waiting for range data.

Cause: Terminate aborts ChunkedStreamManager, and _requestChunks swallows the rejection once it is aborted. NetworkPdfManager.ensure then retries, hits MissingDataException again and calls requestRange, which created a new request after the abort that nothing ever settled, so the termination never finished.

Change (in src/core/chunked_stream.js): range requests made after ChunkedStreamManager.abort() now reject right away with the abort reason, so ensure stops retrying and destroy() can finish. Two background requests are also skipped once aborted.

Tests: 5 new unit specs in test/unit/chunked_stream_spec.js (registered in clitests.json and jasmine-boot.js), including one that checks ensure stops retrying after an abort. Without the fix that regression spec hangs.

Verification (author's run, I did not re-run it):

  • New spec: 5/5 pass.
  • Full node unit suite, 3 random-order runs of 1628 specs: 50 failures, identical to the baseline without this change (environment: no DOM/Worker in Node, missing test PDFs).
  • eslint and prettier clean.
  • Not run: browser, integration and reference tests, PDF-dependent suites, and an end-to-end repro in a browser.

@Snuffleupagus

Copy link
Copy Markdown
Collaborator

This looks completely AI generated, and given the importance of this code there needs to be a reasonable expectation that there's a knowledgeable human actually involved here.

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.

PDFDocumentLoadingTask.destroy() never resolves when called while a page waits for range data

2 participants