diff --git a/packages/runtime/src/createRoot.ts b/packages/runtime/src/createRoot.ts index 00a1ea335f..ecd01247ae 100644 --- a/packages/runtime/src/createRoot.ts +++ b/packages/runtime/src/createRoot.ts @@ -36,6 +36,7 @@ import { isolatedTemplateRegistryMap, registerIsolatedTemplates, } from "./internal/IsolatedTemplates.js"; +import { hooks } from "./internal/Runtime.js"; export interface CreateRootOptions { portal?: HTMLElement; @@ -151,6 +152,9 @@ export function unstable_createRoot( formStateStoreMap: new Map>(), isolatedRoot, unsafe_penetrate, + sys: { + ...hooks?.auth?.getAuth(), + }, } as Partial as RuntimeContext; if (url) { diff --git a/packages/runtime/src/internal/Renderer.ts b/packages/runtime/src/internal/Renderer.ts index b3720e1dd5..8d062b04a2 100644 --- a/packages/runtime/src/internal/Renderer.ts +++ b/packages/runtime/src/internal/Renderer.ts @@ -26,7 +26,7 @@ import { asyncComputeRealPropertyEntries, constructAsyncProperties, } from "./compute/computeRealProperties.js"; -import { resolveData } from "./data/resolveData.js"; +import { clearResolveCache, resolveData } from "./data/resolveData.js"; import { asyncComputeRealValue } from "./compute/computeRealValue.js"; import { TrackingContextItem, @@ -944,6 +944,8 @@ async function legacyRenderBrick( return false; } + clearResolveCache(); + const [ scopedRuntimeContext, tplStateStoreScope, diff --git a/packages/runtime/src/internal/data/resolveData.ts b/packages/runtime/src/internal/data/resolveData.ts index ba129a5548..9f3d0f380c 100644 --- a/packages/runtime/src/internal/data/resolveData.ts +++ b/packages/runtime/src/internal/data/resolveData.ts @@ -82,10 +82,10 @@ export async function resolveData( ) as Promise, ]); - // `clearResolveCache` maybe cleared during the above promise being + // `clearResolveCache` maybe called during the above promise being // fulfilled, so we manually mark it as stale for this case. const renderId = resolveOptions?.renderId; - const stale = !!renderId && renderId !== _internalApiGetRenderId(); + const isStale = () => !!renderId && renderId !== _internalApiGetRenderId(); const promise = resolveByProvider( providerBrick, @@ -94,7 +94,7 @@ export async function resolveData( actualContractConf?.params ? actualContractConf : (actualArgs ?? []), resolveOptions, args, - stale + isStale ); let { transform } = resolveConf; @@ -137,7 +137,7 @@ export async function resolveByProvider( args: unknown[] | UseProviderContractConf, options?: ResolveOptions, originalArgs?: unknown[], - stale?: boolean + isStale?: () => boolean ) { let cacheKey: string; try { @@ -171,7 +171,7 @@ export async function resolveByProvider( return brick[method](...finalArgs); })(); - if (!stale) { + if (!isStale?.()) { cache.set(cacheKey, promise); } }