1// Detects the Cache Components anti-pattern where `'use cache'` doesn't dedupe across2// separate `<Suspense>` boundaries — each boundary triggers a separate evaluation of the3// "shared" cached function, multiplying invocations and ISR write pressure.4//5// Simplified single-file heuristic (cross-file segment analysis is out of scope):6// File contains `'use cache'` directive (or `use cache` keyword)7// AND file has 2+ `<Suspense ...>` boundaries8// AND a repeated fetch URL or function call appears in the body.9//10// False positives are tolerable: the support-topic body recommends a known-good remediation11// (hoist promise to page, or move to `'use cache: remote'`) whether or not the specific call12// site is the exact one paying the cost. The verifier abstains when the file structure13// doesn't match the pitfall.
19 title: "'use cache' with multiple Suspense boundaries on the same data",
20 severity: 'medium',
21 billingDimension: 'function-duration',
22 trafficIndependent: false,
23 description:
24 "Default `'use cache'` does not dedupe identical calls across separate `<Suspense>` boundaries on the same render. Each boundary re-invokes the cached function, multiplying function-duration cost and inflating ISR write churn when the output is large.",
25 fix:
26 "Hoist the promise to the page level (`const dataPromise = fetchData()` at the top, passed down to each Suspense child) OR move the shared fetch into a `'use cache: remote'` data-access layer so cross-request and cross-boundary dedupe applies.",