Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF.js stuck without feedback when Content-Range header is missing #19075

Open
Rob--W opened this issue Nov 20, 2024 · 0 comments
Open

PDF.js stuck without feedback when Content-Range header is missing #19075

Rob--W opened this issue Nov 20, 2024 · 0 comments
Labels

Comments

@Rob--W
Copy link
Member

Rob--W commented Nov 20, 2024

The NetworkManager expects a Content-Range header in a specific format:

const rangeHeader = xhr.getResponseHeader("Content-Range");
const matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);

If the header is missing or does not have the expected value, the regex will be null and the network manager throws at that point, and neither pendingRequest.onError nor pendingRequest.onDone is invoked.

To reproduce:

  • Cherry-pick the patch with tests from Add test cases for redirected responses #19074 (if not already landed)
  • In the test/webserver.mjs, comment out response.setHeader("Access-Control-Expose-Headers", "Content-Range");
  • Run the test from that patch: http://[::1]:8888/test/unit/unit_test.html?spec=redirects%20block

Expected:

  • Test runs to completion.

Actual:

  • Test stuck and times out, console shows the following error:

Uncaught TypeError: can't access property 1, matches is null
onStateChange http://[::1]:8888/src/display/network.js:162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants