Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/runtime/src/createRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
isolatedTemplateRegistryMap,
registerIsolatedTemplates,
} from "./internal/IsolatedTemplates.js";
import { hooks } from "./internal/Runtime.js";

export interface CreateRootOptions {
portal?: HTMLElement;
Expand Down Expand Up @@ -151,6 +152,9 @@ export function unstable_createRoot(
formStateStoreMap: new Map<string, DataStore<"FORM_STATE">>(),
isolatedRoot,
unsafe_penetrate,
sys: {
...hooks?.auth?.getAuth(),
},
} as Partial<RuntimeContext> as RuntimeContext;

if (url) {
Expand Down
4 changes: 3 additions & 1 deletion packages/runtime/src/internal/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -944,6 +944,8 @@ async function legacyRenderBrick(
return false;
}

clearResolveCache();

const [
scopedRuntimeContext,
tplStateStoreScope,
Expand Down
10 changes: 5 additions & 5 deletions packages/runtime/src/internal/data/resolveData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ export async function resolveData(
) as Promise<UseProviderContractConf | null>,
]);

// `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,
Expand All @@ -94,7 +94,7 @@ export async function resolveData(
actualContractConf?.params ? actualContractConf : (actualArgs ?? []),
resolveOptions,
args,
stale
isStale
);

let { transform } = resolveConf;
Expand Down Expand Up @@ -137,7 +137,7 @@ export async function resolveByProvider(
args: unknown[] | UseProviderContractConf,
options?: ResolveOptions,
originalArgs?: unknown[],
stale?: boolean
isStale?: () => boolean
) {
let cacheKey: string;
try {
Expand Down Expand Up @@ -171,7 +171,7 @@ export async function resolveByProvider(
return brick[method](...finalArgs);
})();

if (!stale) {
if (!isStale?.()) {
cache.set(cacheKey, promise);
}
}
Expand Down
Loading