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

Inconsistent revalidation behaviour between action and clientAction when returning 400 #12646

Open
meln1k opened this issue Dec 27, 2024 · 0 comments
Labels

Comments

@meln1k
Copy link

meln1k commented Dec 27, 2024

I'm using React Router as a...

framework

Reproduction

  1. Add the following route:
import { Form, data } from "react-router";

export async function loader() {
    return { foo: "bar" };
}

export async function action() {
    return data(error, { status: 400 });
}

export async function clientAction() {
    const error = { error: "foo" };
    console.log("returning error", error);
    return data(error, { status: 400 });
}

export default function ClickMeForm() {
    return (
        <Form method="post">
            <button>
                Click me
            </button>
        </Form>
    )
}
  1. Submit the form, revalidation happens

  2. Comment out the clientAction

  3. Submit the form, revalidation does not happen

System Info

System:
    OS: macOS 15.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 13.23 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.4.0 - /opt/homebrew/bin/node
    npm: 10.9.2 - /opt/homebrew/bin/npm
    pnpm: 9.12.1 - /opt/homebrew/bin/pnpm
  Browsers:
    Brave Browser: 131.1.73.104
    Chrome: 131.0.6778.205
    Safari: 18.2
  npmPackages:
    @react-router/dev: ^7.0.1 => 7.1.1 
    @react-router/express: ^7.0.1 => 7.1.1 
    @react-router/node: ^7.0.1 => 7.1.1 
    react-router: ^7.0.1 => 7.1.1 
    vite: ^5.4.11 => 5.4.11

Used Package Manager

npm

Expected Behavior

Client action and server action should handle the errors the same way and do not revalidate if a 400 response returned.

Actual Behavior

Server action and client action behaviours are different when 400 is returned. Error in server action does not cause revalidation, but the client action does revalidate in case of an error.

@meln1k meln1k added the bug label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant