(props: React.PropsWithChildren<{ scopeKey?: string | null }>)
| 10 | } from "./server-connection"; |
| 11 | |
| 12 | function ExecutorRegistryProvider(props: React.PropsWithChildren<{ scopeKey?: string | null }>) { |
| 13 | const connection = useExecutorServerConnection(); |
| 14 | // The org scope MUST be part of the registry key on org-scoped hosts: query |
| 15 | // atoms key their cache entries on the request shape alone (the org selector |
| 16 | // header is injected in transformClient, invisible to the atom family key), |
| 17 | // so without it a cached result fetched under one org would serve under |
| 18 | // another for its TTL. Keying the registry tears the whole cache down |
| 19 | // whenever the scope changes — including bare-URL → slugged canonicalization, |
| 20 | // which discards any header-less (server-rejected) fetches from first paint. |
| 21 | // |
| 22 | // The scope also becomes the header authority (setActiveOrgSlugOverride) — |
| 23 | // synchronously, during render, BEFORE the keyed registry below mounts and |
| 24 | // its atoms fire their first fetches. window.history lags the router during |
| 25 | // client-side navigations, so deriving the header from window.location alone |
| 26 | // would scope those first fetches to the OLD URL. Browser only: the header |
| 27 | // injection never runs during SSR, and the worker's module state is shared |
| 28 | // across concurrent requests. |
| 29 | if (props.scopeKey !== undefined && globalThis.window) { |
| 30 | setActiveOrgSlugOverride(props.scopeKey); |
| 31 | } |
| 32 | const key = props.scopeKey ? `${connection.key}#${props.scopeKey}` : connection.key; |
| 33 | return <RegistryProvider key={key}>{props.children}</RegistryProvider>; |
| 34 | } |
| 35 | |
| 36 | export const ExecutorProvider = ( |
| 37 | props: React.PropsWithChildren<{ |
nothing calls this directly
no test coverage detected