react-router icon indicating copy to clipboard operation
react-router copied to clipboard

[Bug]: fetcher.load revalidate when navigation submit without running revalidate function

Open CurryYangxx opened this issue 7 months ago • 4 comments

What version of React Router are you using?

6.23.0

Steps to Reproduce

use this repo branch: https://github.com/Kong/insomnia/tree/perf/modify-initial-entry

we have a loader fetch here: https://github.com/Kong/insomnia/blob/f364d717df2e37b542443586fe09656b46579350/packages/insomnia/src/ui/routes/project.tsx#L614

When trigger navigate in this line first time: https://github.com/Kong/insomnia/blob/f364d717df2e37b542443586fe09656b46579350/packages/insomnia/src/ui/routes/project.tsx#L1051

The permission loader revalidates without running revalidate function in the config.

I dig into the source code.I found it go into this if condition.The loader was canceled because of action submit in this Component.But I found finally the loader is fulfilled and can get data from fetcher. I think maybe it should be deleted from the cancelledFetcherLoads array.Is there any race condition issue?

else if (cancelledFetcherLoads.includes(key)) {
      // Always revalidate if the fetcher was cancelled
      shouldRevalidate = true;
    }

https://github.com/remix-run/react-router/blob/77fca6e9f975b3b9732429085cacaf008d4a9845/packages/router/router.ts#L4397

Expected Behavior

The loader should determine if revalidate through the revalidate function.

Actual Behavior

The loader revalidate when navigation.

CurryYangxx avatar Jun 25 '24 09:06 CurryYangxx