Skip to content

Conversation

brophdawg11
Copy link
Contributor

This has primarily 2 use cases:

  • When using v7_fetcherPersist, we lost the ability to actually cancel/abort fetches if a fetcher was unmounted, so this gives the users a programmatic API to achieve the previous behavior if necessary
  • When "streaming" data via the user of promises, once the fetcher has returned to "idle" there's no good way to abort/cancel the ongoing streaming data since we only tracked the controller in the router while the fetcher was in a non-idle state. This keeps those controllers around inside the router until the fetcher is deleted so that they can be programatically aborted after returning to idle

When calling abortFetcher, we simply abort the controller which will proxy through to the request.signal in the loader so you can use that to reject the promises and trigger the <Await errorElement>:

function loader({ request }) { return { critical: "CRITICAL", lazy: new Promise((resolve, reject) => { request.signal.addEventListener("abort", () => reject(request.signal.reason) ); setTimeout(() => resolve("LAZY"), 3000); }), }; }
Copy link

changeset-bot bot commented Sep 11, 2024

🦋 Changeset detected

Latest commit: 22da242

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
react-router-dom Minor
@remix-run/router Minor
react-router Minor
react-router-dom-v5-compat Minor
react-router-native Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brophdawg11 brophdawg11 reopened this Aug 19, 2025
@brophdawg11
Copy link
Contributor Author

  • Get updated to latest dev
  • Remove abort
  • Make reset abort if in flight
  • Add unstable_ for an alpha release
@brophdawg11
Copy link
Contributor Author

Closed in favor of #14206

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