Rendering
Single-flight cache reads
An application-level in-flight map coalesces concurrent reads for the same key within one process. It is not a persistent result cache or distributed lock. Delete the entry after completion or failure so later callers can retry. In production bound key cardinality and loader duration; use public or correctly isolated keys. The example assumes trusted bounded inputs. Source: https://nextjs.org/docs/app/guides/self-hosting. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.
Formal Syntax & Structure
nextjs syntaxnextjs
Map<key, Promise<value>>Working Example
Example Snippetnextjs
const pending = new Map<string, Promise<string>>();function once(key: string, read: () => Promise<string>) { const active = pending.get(key); if (active) return active; const job = Promise.resolve().then(read).finally(() => pending.delete(key)); pending.set(key, job); return job;}