Skip to content

Commit 92d6a5b

Browse files
committed
fix(ssr): cross-guard preload/preloadModule against both script and module executables
The client-side preload suppression was updated to treat classic Float scripts and preinitModule as one executable set via resourceState().scripts, but the SSR preload paths were not updated symmetrically: - preload(as:'script') only checked 'script:' keys, missing 'module:' from preinitModule - preloadModule only checked 'module:' keys, missing 'script:' from Float scripts This caused SSR to emit redundant preload tags that the hydrating client would suppress, creating a client/server Float hint asymmetry. Add the missing cross-guards so both SSR preload paths mirror the client's unified executable identity.
1 parent cae7135 commit 92d6a5b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎packages/octane/src/runtime.server.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8094,7 +8094,8 @@ export function preload(href: string, options: { as: string } & Record<string, u
80948094
// coalesced away when the preinit lands (see the hintHtml delete there).
80958095
if (HEAD !== null) {
80968096
if (as === 'style' && HEAD.hints.has('sheet:' + value)) return;
8097-
if (as === 'script' && HEAD.hints.has('script:' + value)) return;
8097+
if (as === 'script' && (HEAD.hints.has('script:' + value) || HEAD.hints.has('module:' + value)))
8098+
return;
80988099
if (as === 'style' || as === 'script') {
80998100
let subset: Record<string, unknown> | null = null;
81008101
for (const k of ['crossOrigin', 'integrity', 'nonce', 'fetchPriority', 'referrerPolicy']) {
@@ -8306,8 +8307,9 @@ export function ssrScriptResource(attrs: Record<string, unknown> | null): string
83068307
export function preloadModule(href: string, options?: Record<string, unknown>): void {
83078308
const value = coerceHintHref(href);
83088309
if (value === null) return;
8309-
// A module that preinitModule already executed in this pass needs no preload.
8310-
if (HEAD !== null && HEAD.hints.has('module:' + value)) return;
8310+
// A module that preinitModule or a Float script already executed in this pass needs no preload.
8311+
if (HEAD !== null && (HEAD.hints.has('module:' + value) || HEAD.hints.has('script:' + value)))
8312+
return;
83118313
const key = 'modulepreload:' + value;
83128314
const safeHref = sanitizeURL(value);
83138315
emitHeadHint(

0 commit comments

Comments
 (0)