resource() has a race condition where a request change during the loader phase that happens at the right time will be dropped, causing the resource to display stale data. This seems to happen if:
- While the resource is loading, the request changes
- Before the
effect() can run, the Promise for the previous load resolves, which sets the resource out of loading state.
- The
effect runs for the new request, but the resource is no longer a valid loading state per this check.
The condition in (3) is really trying to guard that the resource hasn't been set into Local state after the request changed. The check here is probably unnecessarily strict, but also, we should have a more robust way of detecting this condition.
resource()has a race condition where a request change during the loader phase that happens at the right time will be dropped, causing the resource to display stale data. This seems to happen if:effect()can run, thePromisefor the previous load resolves, which sets the resource out of loading state.effectruns for the new request, but the resource is no longer a valid loading state per this check.The condition in (3) is really trying to guard that the resource hasn't been set into
Localstate after the request changed. The check here is probably unnecessarily strict, but also, we should have a more robust way of detecting this condition.