Skip to content

Action returning 4XX status code called using fetcher does unnecessary revalidationΒ #13062

@lukejagodzinski

Description

@lukejagodzinski

I'm using React Router as a...

framework

Reproduction

https://github.com/lukejagodzinski/rr-should-revalidate-repro

  1. Run npm run dev
  2. Open app in the browser
  3. Open "Network" tab in the browser dev tools
  4. Click the "Use fetcher" button to call action using fetcher
  5. Observe that the request is made and 422 response is returned and the unnecessary revalidation is triggered. This should not happen according to docs.
  6. Click the "Use form submit" button to call the same action but using regular form submission
  7. Observe that the request is made and 422 response is returned but the revalidation is not triggered. This is the expected behavior.

You can also fix the issue by uncommenting the shouldRevalidate function in app/routes/home.tsx:14. However, that should not be necessary.

System Info

System:
    OS: macOS 15.1.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 9.68 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
    bun: 1.0.28 - ~/.bun/bin/bun
  Browsers:
    Chrome: 133.0.6943.99
    Safari: 18.1.1
  npmPackages:
    @react-router/dev: ^7.2.0 => 7.2.0 
    @react-router/node: ^7.2.0 => 7.2.0 
    @react-router/serve: ^7.2.0 => 7.2.0 
    react-router: ^7.2.0 => 7.2.0 
    vite: ^5.4.11 => 5.4.14

Used Package Manager

npm

Expected Behavior

RR shouldn't revalidate loaders when action returning error is being called using fetcher

Actual Behavior

RR revalidates loaders after action returning error is being called using fetcher

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions