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

Request for the source is not cancelled even if the Document is unmounted #1893

Open
4 tasks done
techie014 opened this issue Oct 2, 2024 · 0 comments
Open
4 tasks done
Labels
bug Something isn't working

Comments

@techie014
Copy link

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

If the Document component is unmounted, then the request for the resource should be cancelled. It was the usual behaviour of v9.1.0. But it changed in v9.1.1. Now, it doesn't cancel the fetch request.

Steps to reproduce

  • Throttle the network from the devtool
  • Mount a Document with a url of a pdf
  • Before it's loaded, change the url or unmount the Document

Expected behavior

The request to the resource should be cancelled.

Actual behavior

The requests are still running in the background and it's throttling the network speed.

Additional information

Consider these two scenarios where:

  • One can open the modal and close it before the documents are loaded
  • One can navigate left or right to see the other documents

In both cases, the instances of the Document components will be unmounted. In v9.1.0, the requests would have been cancelled. But that version had an issue mentioned here: #1062 which was fixed by this PR: #1877

With the new release v9.1.1, the requests don't get cancelled anymore. So, if I navigate through 10 PDFs which were not loaded while navigating, they don't get cancelled which in turn throttles the network speed for the ones I want to view.

Environment

  • Browser (if applicable): Chrome v129
  • React-PDF version: 9.1.1
  • React version: 16.14.0
  • Bundler name and version (if applicable):
@techie014 techie014 added the bug Something isn't working label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant