From 4acbde52b4eda661611f04b40003085d0cc9040e Mon Sep 17 00:00:00 2001 From: LeSingh1 Date: Tue, 19 May 2026 00:44:20 -0700 Subject: [PATCH] Isolate context id space inside createComponent under NoHydration When the SSR shared context has noHydrate set, createComponent was calling the child component directly without pushing a new HydrationContext. That meant resources created in nested components shared the parent's id space, and because Suspense resets ctx.count to 0 inside its boundary, two resources at different positions could end up keyed by the same context id and the inner resource would read back the outer one's value. Always isolate per-component, even under noHydrate. nextHydrateContext already preserves the noHydrate flag via spread, so downstream hydration markers are still skipped; the only behavior change is that resource ids stay unique across components inside . Closes #2546 --- packages/solid/src/server/rendering.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/solid/src/server/rendering.ts b/packages/solid/src/server/rendering.ts index 402119d72..7416b6d06 100644 --- a/packages/solid/src/server/rendering.ts +++ b/packages/solid/src/server/rendering.ts @@ -146,7 +146,15 @@ export function createUniqueId(): string { } export function createComponent(Comp: (props: T) => JSX.Element, props: T): JSX.Element { - if (sharedConfig.context && !sharedConfig.context.noHydrate) { + if (sharedConfig.context) { + // Even under noHydrate we still need to isolate the id space for each + // component, so that `createResource` calls in sibling/nested components + // do not collide on the same context id when a parent `Suspense` resets + // `count` back to 0. Without this, a non-hydrating render of + // `` (each with a resource) + // produces two resources sharing the same id key in + // `context.resources` and the inner resource reads back the outer one's + // value. See #2546. const c = sharedConfig.context; setHydrateContext(nextHydrateContext()); const r = Comp(props || ({} as T));