Fix #14768 useFetchers breaking on deferred routes with Suspense/Await #14805
Fix #14768 useFetchers breaking on deferred routes with Suspense/Await #14805Axadali wants to merge 7 commits intoremix-run:mainfrom
Conversation
…ic rendering not possible with Suspense/Await remix-run#14768
|
Hi @Axadali, Welcome, and thank you for contributing to React Router! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run. Thanks! - The Remix team |
🦋 Changeset detectedLatest commit: f573a9c The changes in this PR will be included in the next version bump. 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 |
|
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
Description:
This PR fixes an issue where multiple concurrent useFetcher() submissions would collapse into a single effective inflight fetcher on routes that use deferred loaders with Suspense/Await.
Problem
On deferred routes, only the first fetcher would enter the loading state while others remained in submitting state or vanished entirely, breaking parallel optimistic rendering. This was different from blocking routes where multiple concurrent fetchers worked correctly.
Solution
Modified the getUpdatedRevalidatingFetchers function in packages/react-router/lib/router/router.ts to preserve fetchers that are already in "submitting" or "loading" states during deferred revalidation. The fix adds a condition to only update fetchers that are not already active:
Changes Made
1. Updated getUpdatedRevalidatingFetchers function to preserve active fetchers during revalidation
2. Added proper test cases to verify the fix works correctly
3. Created changeset file to document the fix
Verification
- Multiple concurrent fetchers now maintain independent states on deferred routes
- Behavior is now consistent between blocking and deferred routes
- All fetchers progress independently: submitting → loading → idle
- Maintains backward compatibility with existing functionality