Skip to content

[Bug]: Fetcher Revalidation Race Condition (Remix) #10473

@brophdawg11

Description

@brophdawg11

What version of React Router are you using?

6.11.0

Steps to Reproduce

https://discord.com/channels/@me/1105622443453857842/1105623069365649458

It seems there's a race condition in Remix when the fetcher.load kicks off on initial render, and then the subsequent render-driven navigate triggers a shouldRevalidate call on the fetcher - and if the fetcher has not yet loaded the route module for the Remix route it bombs out.

The fetcher probably shouldn't attempt to revalidate at all since it's tied to a hardcoded route. With navigational loaders even on reused routes we still want to call shouldRevalidate so folks can opt-in, but with fetchers they can manually re-trigger via fetcher.load if necessary.

I do worry this fix might still have the same race condition bug if the render-driven navigation comes from useSubmit- since fetchers should attempt to revalidate after actions. But really GET-driven initial renders shouldn't trigger mutations. Worth digging a bit deeper into the Remix side of things to see if there's any avenues to look into there.

Expected Behavior

Fetcher does not try to revalidate and does not call shouldRevalidate

Actual Behavior

Fetcher is trying to revalidate before the route module loads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions