In the client-side implementation of suspense/useFind, useFindClient is used.
PR #433 introduced useSyncEffect, which sets a 1000ms timeout.
const useSyncEffect = (effect, deps) => {
const [cleanup, timeoutId] = useMemo(
() => {
const cleanup = effect();
const timeoutId = setTimeout(cleanup, 1000);
↖︎here
return [cleanup, timeoutId];
},
deps
);
useEffect(() => {
clearTimeout(timeoutId);
return cleanup;
}, [cleanup]);
};
When used with Suspense, if code after useFindClient (e.g., the Suspense-compatible useSubscribe) throws a promise and triggers Suspense fallback:
- The
useEffect inside useSyncEffect is not called (due to rendering being suspended),
- But the 1000ms timeout remains active in the background.
Once Suspense resolves the promise and re-renders the component (typically in <1000ms), the timeout fires after re-rendering, triggering its cleanup logic. This prematurely terminates useFind's reactivity
In the client-side implementation of
suspense/useFind,useFindClientis used.PR #433 introduced
useSyncEffect, which sets a 1000ms timeout.When used with Suspense, if code after
useFindClient(e.g., the Suspense-compatibleuseSubscribe) throws a promise and triggers Suspense fallback:useEffectinsideuseSyncEffectis not called (due to rendering being suspended),Once Suspense resolves the promise and re-renders the component (typically in <1000ms), the timeout fires after re-rendering, triggering its cleanup logic. This prematurely terminates useFind's reactivity