Capítulo 75 de 116
cacheSignal() returns an AbortSignal tied to the lifetime of the current server-render cache (Ch 74), letting cached async work know when it's safe to abort because the cache it belongs to is being torn down.
cache: exists specifically to support cleanup for work memoized via cache — when the request-scoped cache is discarded (the render finished or was aborted), the signal fires so any still-in-flight cached operation can cancel itself instead of continuing pointlessly.AbortSignal semantics: since it's a real AbortSignal, it composes with any API that already accepts one (e.g. fetch(url, { signal: cacheSignal() })) — no React-specific cancellation protocol to learn.cache, this is part of the React Server Components server-rendering surface, not something used in Client Components.const getUser = cache(async (id) => {
return fetch(`/api/users/${id}`, { signal: cacheSignal() }).then(r => r.json());
});
fetch, so the request cancels automatically if the surrounding cache is torn down before it resolves.AbortSignal — plug it into any cancellation-aware API the same way you would any other abort signal.cache, in a Server Components context.cache belong to.