Skip to content

Commit e0e4224

Browse files
ryansolidclaude
andauthored
fix(solid): hydration never asks again for an answer the server already sent (#4313)
* fix(solid,web): draw an Errored fallback for a Loading's async failure, and adopt it (#4287) Outside a server component, a <Loading> whose async read failed during a streamed render settled its fragment blank, and the hydrating client rendered the failed boundary from scratch: it asked again and showed the loading fallback. Server: the failing <Loading> now asks the enclosing <Errored> for its outcome outside server components too, passing its own id. The Errored answers only when that Loading is all of its content (its resolved markup is the Loading's placeholder): its fallback is drawn into the fragment, or inlined pre-flush, and the error is serialized at the Errored id. Deeper in the content it answers nothing, as before. A rejected fragment's template is marked `e`, and `$dfr` records the nodes it swaps in for it. Client: inside a hydrated Errored's no-claim content run, a <Loading> runs its content with its data adopted instead of waiting on its fragment, so the Errored holds the client's own error and tracks the content's inputs (#4273). A boundary that claimed its fallback and then renders a rejected fragment fresh clears the nodes the swap put in first, so nothing of the server's outcome is left beside the client's render. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(solid): serialize an Errored's error only when its fallback markup is sent When a streamed <Loading> fails after the shell and asks the enclosing <Errored> for its outcome, the fallback may hold an async hole that has not resolved yet. renderOutcome then returns no markup (the fragment settles as a plain rejection), but handleError had already serialized the error at the Errored id. A client hydrating after the failure read that record, claimed a fallback that was never sent, and went blank with a hydration key miss. The outcome path now defers the record and writes it only once the fallback resolved to finished markup. Without it the client renders the failure itself, as on `next`. Server-only; no client bytes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018LY7F9czoRqdMEvk2QwPr1 * fix(solid,web): stream a parked Errored fallback once its async hole resolves (#4306) An <Errored> whose fallback reads async data, around a <Loading> that fails after the shell inside an outer <Loading> still pending, lost its region: the outcome render met the fallback's pending hole, answered no markup, and the parked fragment spliced a blank into the outer one while its `_fr` resolved. The client claimed against the blank and showed nothing there, with hydration warnings. renderOutcome now answers a still-resolving fallback with a function that waits out its holes and returns the finished markup, serializing the error only then. The <Loading> calls it only while its fragment is parked in an enclosing pending one (the registry's new `parked()` query on the settle function), where nothing of the failure shows yet: the outer fragment carries the fallback, or, if the outer settles first, the inner fragment streams it when it lands. A failure in a region already shown settles at once, as before. Server-only; no client bytes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(solid,web): a failed Errored always waits for its fallback's async holes (#4306) Per RULES-DERIVED D-18 (a swap to a fallback waits for the fallback to be ready), the wait for an Errored fallback's async holes no longer depends on the fragment being parked. A <Loading> that fails after the shell under an <Errored> whose fallback is still resolving keeps its placeholder until the finished fallback is ready, then streams it with the error record, in the parked case (carried by the outer fragment while that is pending) and the unparked one alike. The registry's `parked()` query is dropped. #4303's async-fallback scenario now expects the server's finished fallback and its record: a client hydrating after the failure arrived claims it and asks nothing again. Server-only; no client bytes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(solid,web): a hydrated failure re-serves the server's error instead of asking again (#4287, #4306) A client hydrating mid-stream asked again for an async memo whose server read failed, and flashed back to the inner <Loading> fallback after the failure showed: Errored > Loading > read, with the read failing after the shell, unparked (the fragment rejects and the client renders the failure fresh over the swapped-in Errored fallback) or parked in a pending outer Loading (the outer resume runs the hydrated Errored's content, NO_CLAIM). Both content runs read the shell memo a cycle after its error landed, and a later tracked read retries an errored async node (PJ-R35). The retry re-enters the hydration latch, which since f3da41e has taken every re-entry for a dependency change ("re-entry is always invalidation- driven"), and since b68a907 computes such a rerun at once for a shell node outside the claim in progress: one real ask, the Loading fallback for its duration. Before f3da41e the latch re-served the serialized answer on every re-entry while hydrating, so the retry asked nothing. Inside a hydrated failure's content run (NO_CLAIM) a latched rerun now re-serves the server's answer, its error included, and arms nothing. A rejected fragment's fresh render runs as such a content run when the swap brought the outcome the server drew for the failure (the reveal record lists its nodes); to make that list the outcome alone, a rejected fragment with no outcome streams an empty template instead of a lone space. Uncontained failures (no outcome) keep rendering fresh as before. Tests: the #4287/#4306 hydration specs stream piece by piece with a clock tick between pieces (the plain-fallback case only passed because no flush ran between the error landing and the fresh read), assert 0 asks in both modes and no flash back to a loading fallback, and cover the parked plain-fallback scenario, which now has an ask counter and an update pass (the Errored tracks the memo, #4273). Size: 0 B on every CSR scenario (compiled floor 9,966 B); +65-71 B minified on the hydrating scenarios. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(solid): a served source's arrival re-serves its dependents' answers instead of asking again Hydrated mid-stream, an async shell memo `b` reading another, `a`, both read only inside a streamed <Loading>, asked again when `a`'s server answer arrived: the landing re-ran `b`, and the hydration latch took the rerun for a client write (f3da41e's "re-entry is always invalidation- driven"; b68a907 computes it at once for a shell node). The server's `b` was computed from that same `a`; nothing on the client diverged. The latch now has one rule: a latched rerun inside hydration's own pass over served answers (NO_CLAIM) re-serves its own answer and arms nothing. That pass is a hydrated failure's content run (the Errored's, or a rejected fragment's fresh render over the outcome the server drew, from the previous commit) and, new here, a served answer's arrival: readHydratedValue hands the runtime a thenable whose landing runs, with the flush that carries it, under NO_CLAIM. The NO_CLAIM check moves to the head of the latch rule, so in-claim and held reruns there re-serve without arming a takeover too. Client writes still compute (the write-before-resume, nav-before-resume and hydration-latch pins), and a retry outside that pass still follows the client rule. Tests: a parity scenario and spec for the b-reads-a shape (0 asks loaded and streamed piece by piece with clock ticks, one real ask after a client write to their input); both fail before this commit. Size: 0 B on every CSR scenario (compiled floor 9,966 B); +19-27 B minified on the hydrating scenarios over the previous commit. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * fix(solid): a served pass never swallows a client write A served answer's arrival is hydration's own pass (NO_CLAIM): a latched node re-running there re-serves its server answer. A client write carried by that same flush must still make the node compute. - Client writes already made (pending, unflushed) flush first, outside the pass (`servedPass`). The async runtime's landing flushes synchronously, and that flush would otherwise carry them. - The pass covers only the flush round its served write lands in (`_servedAt = clock`). An effect's write runs in a later round of the same flush, and a latched node re-run there computes. The latch tests `clock > _servedAt`. `@solidjs/signals` exports its flush-round counter (`clock`), an internal live binding, at 0 B. Landings cannot be coalesced into one pass per microtask batch without changing signals. `asyncWrite` already flushes synchronously on every landing (`schedule(); flush()`) at the #4308 head, so a served pass adds no flush per landing. Its trailing `flush()` is a no-op after a value landing. Tests: in served-source-landing, a write before the flush and an effect's write in the landing's flush both give the written value with 1 ask. Both fail on 2b2990a. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * perf(solid): golf the served-pass client code This changes no behaviour. Client bytes over next go from about +130 B to +58 B minified. - A hydrated `<Errored>`'s content run and a served pass are one window kind: `_claimOwner = ~clock`, a window over no owner for the flush round it opened in. `~` keeps it truthy when clock is 0. - That replaces both `NO_CLAIM` and `_servedAt`. The latch checks one thing, `_claimOwner !== ~clock`, and a later round of an arrival's flush (an effect's write) still computes. `isClaiming` reads a number as no owner, so nothing claims, as before. - `servedPass` is curried (`servedPass(f)(x)`), so the arrival thenable is `initP.then(servedPass(a), servedPass(b))`. - A resume clears the hydration flag once, before either branch. The fresh branch's own flush was redundant with the resume's trailing one. The outcome check reads `?.[0]` instead of `?.length`. The pre-flush stays on both paths. Removing it makes the write-before-landing test fail, and comparing only `_claimOwner` without the round makes the effect-write test fail. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015hPxMkC3jg3Uivh65gvaf2 * perf(solid): read the page's _$HY directly on the recover path A recover only runs while hydrating, so the guarded globalThis read is dead weight: -12 B minified on every hydrating and page scenario. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018LY7F9czoRqdMEvk2QwPr1 --------- Co-authored-by: Claude <[email protected]>
1 parent 8f1d9d2 commit e0e4224

31 files changed

Lines changed: 521 additions & 122 deletions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"solid-js": patch
3+
"@solidjs/web": patch
4+
---
5+
6+
A client hydrating mid-stream no longer asks again for an async read whose server answer was an error, nor flashes back to the `<Loading>` fallback after the failure showed (#4287, #4306). The content of a hydrated failure (a hydrated `<Errored>`'s content run, or a rejected fragment's fresh render over the `<Errored>` fallback the server drew) reads a shell memo a cycle after its error landed, and a later tracked read retries an errored async node; the serialized-value latch took that rerun for a client write and computed. Inside such a content run the rerun now re-serves the server's answer and arms nothing. A rejected fragment with no outcome streams an empty template (it was a lone space), so the nodes its swap lists are the server's outcome alone.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"solid-js": patch
3+
---
4+
5+
A memo that adopted its server answer no longer asks again when the server's answer for one of its sources arrives mid-stream. Hydrated mid-stream, an async shell memo `b` reading another, `a`, re-ran when `a`'s server value landed, and the serialized-value latch took that rerun for a client write and computed `b`. The arrival of a served answer, with the flush that carries it, is now hydration's own pass (as a hydrated failure's content run is): a latched node re-running there re-serves its own answer and arms nothing. Only a client write makes it compute.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"solid-js": patch
3+
"@solidjs/signals": patch
4+
---
5+
6+
A served answer's arrival during hydration no longer swallows a client write made in the same flush. Writes made before the arrival flush first, outside hydration's own pass, and a write made during it (an effect's, a later round of the flush) makes a node it reaches compute, so the node shows the written value instead of re-serving the server's answer. `@solidjs/signals` exports its internal flush-round counter (`clock`) for this.

‎packages/signals/src/core/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export {
5656
type QueueCallback
5757
} from "./scheduler.js";
5858
export type { InteractionRef, NavigationRef } from "./attribution-hooks.js";
59-
export { ROOT_ERROR_HOOK } from "./scheduler.js";
59+
export { ROOT_ERROR_HOOK, clock } from "./scheduler.js";
6060
export {
6161
configureClientErrors,
6262
type ClientErrorContext,

‎packages/signals/src/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export {
3838
* outside dev builds.
3939
*/
4040
export { setConsoleFooter } from "./core/index.js";
41+
/** @internal The flush round counter (scheduler.ts): hydration's served pass tells its own round from a later one. */
42+
export { clock } from "./core/index.js";
4143
/** @internal The pre-write hook (`setWriteHook` in core/core.ts); the server-components client's deferred hydration. */
4244
/** @internal Plain-signal identities and the dev read watch (dependency edges; the server-components client). */
4345
export { setWriteHook, setSignalIdentities, setReadWatch, signalName } from "./core/index.js";

‎packages/solid/src/client/hydration.ts‎

Lines changed: 88 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
createRenderEffect as coreRenderEffect,
2121
createEffect as coreEffect,
2222
setSnapshotCapture,
23+
clock,
2324
markSnapshotScope,
2425
releaseSnapshotScope,
2526
clearSnapshots,
@@ -53,6 +54,8 @@ import { IS_DEV, IS_OBSERVE } from "./core.js";
5354
// enableHydration().
5455
import { hydrateStoreLike } from "./store-hydration.js";
5556

57+
declare const _$HY: any;
58+
5659
type HydrationSsrFields = {
5760
/**
5861
* Defer the SSR stream flush until this primitive's first value is
@@ -304,11 +307,14 @@ let _pendingBoundaries = 0;
304307
let _hydrationDone = false;
305308
let _snapshotRootOwner: Owner | null = null;
306309
// The boundary owner whose resume window is open (null during a root pass,
307-
// which claims everything). Reached as `sharedConfig.isClaiming`.
308-
let _claimOwner: Owner | null = null;
309-
// The claim window over no owner: a hydrated `<Errored>`'s content run,
310-
// where nothing claims (hydratedCreateErrorBoundary).
311-
const NO_CLAIM = {} as Owner;
310+
// which claims everything). Reached as `sharedConfig.isClaiming`. Or no
311+
// owner, so nothing claims: `~clock`, a window over the flush round it
312+
// opened in, where a latched node re-serves its server answer
313+
// (readSerializedOrCompute) — hydration's own pass over served answers: a
314+
// hydrated `<Errored>`'s content run (hydratedCreateErrorBoundary) and the
315+
// round a served answer lands in (`servedPass`). Never 0: `~` maps every
316+
// round to a truthy number.
317+
let _claimOwner: Owner | number | null = null;
312318
function isClaiming(): boolean {
313319
if (!_claimOwner) return true;
314320
let owner: Owner | null = getOwner();
@@ -581,6 +587,28 @@ export function syncThenable(value: any) {
581587
};
582588
}
583589

590+
/**
591+
* A served pass: `write(x)` lands a served answer — the server's answer for a
592+
* node arriving (the async runtime writes it and flushes, synchronously),
593+
* or a rejected fragment's fresh render over the outcome the server drew
594+
* (the boundary's trigger) — and the flush round that carries it is
595+
* hydration's own pass over served answers (`_claimOwner`, that round). A
596+
* node that adopted its own server answer re-runs there because the
597+
* server's answer for something it reads arrived, not because a client
598+
* write diverged it, and re-serves that answer (readSerializedOrCompute).
599+
* No client write is swallowed: the ones already made flush first, outside
600+
* the pass, and one made during it (an effect's) runs in a later round of
601+
* the flush, where a node it reaches computes. Runs from a settled promise,
602+
* outside any claim window.
603+
*/
604+
const servedPass = (write: (x?: any) => void) => (x?: any) => {
605+
flush();
606+
_claimOwner = ~clock;
607+
write(x);
608+
flush();
609+
_claimOwner = null;
610+
};
611+
584612
/**
585613
* Unwrap a serialized hydration map entry. Only call when the map HAS an
586614
* entry for this id — presence is the caller's decision (`sharedConfig.has`),
@@ -602,16 +630,20 @@ export function readHydratedValue(initP: any, refresh: () => void, options?: any
602630
// claim against placeholder DOM). Hand the async runtime a clean thenable
603631
// (the settled refs are stamped `s`/`v`, which the core would also
604632
// fast-adopt): the landing applies on the microtask after the walk.
605-
if (hasLoadingWindow(options) && typeof initP.then === "function")
606-
return { then: initP.then.bind(initP) };
607-
if (initP.s === 2) {
608-
// The stamp is the consumption: nothing ever `.then`s the serialized
609-
// promise itself, so observe its rejection here or the deserialized
610-
// record surfaces as an unhandled rejection (#2997).
611-
if (typeof initP.then === "function") initP.then(undefined, noop);
612-
throw initP.v;
633+
if (!hasLoadingWindow(options)) {
634+
if (initP.s === 2) {
635+
// The stamp is the consumption: nothing ever `.then`s the serialized
636+
// promise itself, so observe its rejection here or the deserialized
637+
// record surfaces as an unhandled rejection (#2997).
638+
initP.then?.(undefined, noop);
639+
throw initP.v;
640+
}
641+
if (initP.s === 1) return initP.v;
613642
}
614-
if (initP.s === 1) return initP.v;
643+
// Still in flight (or a loading window's): the runtime lands it, in a
644+
// served pass for the node it lands.
645+
if (typeof initP.then === "function")
646+
return { then: (a: any, b: any) => initP.then(servedPass(a), servedPass(b)) };
615647
}
616648
return initP;
617649
}
@@ -625,7 +657,9 @@ export function readHydratedValue(initP: any, refresh: () => void, options?: any
625657
* not deferred. Arming the takeover gate on that re-entry re-runs exactly
626658
* the diverged nodes against their live sources when hydration ends.
627659
* (Async settles commit through the adopted thenable without re-entering
628-
* the wrapper, so re-entry here is always invalidation-driven.)
660+
* the wrapper, so re-entry here is invalidation-driven — save one: a later
661+
* tracked read retries an errored async node (PJ-R35) with nothing changed.
662+
* A hydrated failure's content run re-serves that one, below.)
629663
*/
630664
const latchedOnce = new WeakSet<object>();
631665

@@ -681,8 +715,16 @@ export function readSerializedOrCompute(compute: (prev: any) => any, prev: any,
681715
// A rerun outside the claim in progress by a node no pending boundary
682716
// holds: its section's hydration is over, so the rerun answers a client
683717
// write and computes, rather than re-adopting the server value until the
684-
// page's last boundary resumes.
685-
if (options?.ssrSource !== "hybrid") {
718+
// page's last boundary resumes. Never in hydration's own pass over
719+
// served answers (`_claimOwner` is `~clock`): a source's server answer
720+
// arriving, or a hydrated failure's content reading the node — a later
721+
// tracked read retries an errored async node (PJ-R35) with nothing
722+
// changed. No client write diverged it there: it re-serves its own
723+
// answer, an error included, and arms nothing — no ask, no loading flash
724+
// (#4287, #4306). A served pass covers the round its answer lands in
725+
// (`servedPass`): a later round of that flush is an effect's write
726+
// re-running the node, which computes.
727+
if (options?.ssrSource !== "hybrid" && _claimOwner !== ~clock) {
686728
let p: Owner | null = o;
687729
while (p && !(p as any)._hp) p = p._parent;
688730
if (!p && !(sharedConfig.hydrating && isClaiming())) return compute(prev);
@@ -1290,13 +1332,15 @@ function hydratedCreateErrorBoundary<T, U>(
12901332
// The content's owner, until a fallback is built.
12911333
let o: any;
12921334
const read = coreErrorBoundary(
1293-
// While hydrating, a claim window over no owner: nothing under it
1294-
// claims. (`hydrateWindow` with no id or scope, hydration already on
1335+
// While hydrating, a claim window over no owner (`~clock`): nothing
1336+
// under it claims. (`hydrateWindow` with no id or scope, hydration already on
12951337
// and the snapshot root marked above, only swaps the claim owner.)
12961338
// A later run claims nothing either way: claims are read only while
12971339
// hydrating.
12981340
() =>
1299-
_hydratingValue ? hydrateWindow("", fn, undefined, ((o = getOwner()), NO_CLAIM)) : fn(),
1341+
_hydratingValue
1342+
? hydrateWindow("", fn, undefined, ((o = getOwner()), ~clock as any))
1343+
: fn(),
13001344
(e, reset) => ((o = 0), fallback(e, reset))
13011345
);
13021346
// No fallback yet: the content ran clean. Hold the server's fallback
@@ -2256,29 +2300,30 @@ function resumeBoundaryHydration(
22562300
checkHydrationComplete();
22572301
return;
22582302
}
2259-
if (shouldHydrate) {
2260-
// A late resume claims against the root this boundary registered under
2261-
// (the captured `scope`), its subtree the snapshot and live scope for
2262-
// the window; the trigger re-runs the boundary's compute inside it.
2263-
hydrateWindow(
2264-
id,
2265-
() => {
2266-
set();
2267-
flush();
2268-
},
2269-
scope,
2270-
o
2271-
);
2272-
} else {
2273-
// The client renders the boundary fresh (recover): no claim.
2274-
_hydratingValue = false;
2275-
set();
2276-
flush();
2277-
}
22782303
// Hydration mode is off once a boundary has resumed — whatever the flag
22792304
// read before (a resume never runs inside a root's synchronous pass; the
2280-
// client-gated nodes the resume created compute in the flush below).
2305+
// client-gated nodes the resume created compute in the flush below). A
2306+
// claiming resume turns it on for its window alone.
22812307
_hydratingValue = false;
2308+
shouldHydrate
2309+
? // A late resume claims against the root this boundary registered under
2310+
// (the captured `scope`), its subtree the snapshot and live scope for
2311+
// the window; the trigger re-runs the boundary's compute inside it.
2312+
hydrateWindow(
2313+
id,
2314+
() => {
2315+
set();
2316+
flush();
2317+
},
2318+
scope,
2319+
o
2320+
)
2321+
: // The client renders the boundary fresh (recover): no claim. Over the
2322+
// outcome the server drew for the failure (an `<Errored>` fallback the
2323+
// swap brought, listed in the reveal record, #4287) it is that
2324+
// failure's content run, as a hydrated `<Errored>`'s is: a served pass.
2325+
// A recover only runs while hydrating, so the page's `_$HY` exists.
2326+
(_$HY.v?.[id]?.[0] ? servedPass(set) : set)();
22822327
flush();
22832328
checkHydrationComplete();
22842329
}
@@ -2860,12 +2905,13 @@ function hydratedCreateLoadingBoundary<T, U>(
28602905
// A parked fragment has settled but not swapped: it waits like a pending one.
28612906
const s = fr && typeof fr === "object" ? (fr.s === 1 && fragmentParked(id) ? 0 : fr.s) : 0;
28622907

2863-
// Inside a hydrated `<Errored>`'s content run, which claims no DOM (the
2908+
// Inside a hydrated `<Errored>`'s content run (`~clock`, a window
2909+
// over no owner), which claims no DOM (the
28642910
// markup is the server's fallback for the failure, #4287), the
28652911
// fragment is never claimed: the content runs now with its data
28662912
// adopted, so the Errored holds the client's own error and tracks its
28672913
// inputs (#4273).
2868-
const unclaimed = _claimOwner === NO_CLAIM;
2914+
const unclaimed = _claimOwner === ~clock;
28692915
// Nothing else consumes a rejected `_fr` promise then — swallow it so
28702916
// a rejected fragment (error finalize or a client-hole handoff) doesn't
28712917
// surface as an unhandled rejection.

‎packages/web/src/server.ts‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3037,14 +3037,20 @@ export function renderToStream(code, options = {}) {
30373037
// outcome — a server <Errored>'s fallback or the boundary's own
30383038
// markup inside a server component (frames-rulings 3.3) — and
30393039
// nothing outside one, where the client twin renders fresh over
3040-
// the blank.
3041-
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
3042-
styles,
3043-
revealGroup,
3044-
error: error
3045-
? ssrSanitizeError(error, null, undefined, undefined, errorScope)
3046-
: error
3047-
});
3040+
// the blank: an empty template, so what its swap lists is the
3041+
// outcome alone (the client reads a listed outcome as the
3042+
// server's answer for the failure, #4287).
3043+
sink.fragment(
3044+
key,
3045+
resolveSSRSelectValues(value !== undefined ? value : error ? "" : " "),
3046+
{
3047+
styles,
3048+
revealGroup,
3049+
error: error
3050+
? ssrSanitizeError(error, null, undefined, undefined, errorScope)
3051+
: error
3052+
}
3053+
);
30483054
item.resolve(error);
30493055
}
30503056
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "async-memo-element-4242-issue-streamed-reference",
33
"shell": "<template id=\"pl-0\"></template>outer<!--pl-0--><script>(self.$R=self.$R||{})[\"\"]=[];_$HY.r[\"0_fr\"]=$R[0]=($R[1]=($R[2]=() => {\n\tconst resolver = {\n\t\tp: 0,\n\t\ts: 0,\n\t\tf: 0\n\t};\n\tresolver.p = new Promise((resolve, reject) => {\n\t\tresolver.s = resolve;\n\t\tresolver.f = reject;\n\t});\n\treturn resolver;\n})()).p;_$HY.r[\"0000\"]=$R[3]=($R[4]=$R[2]()).p;</script>",
4-
"rest": "<template id=\"0\" e> </template><script>($R[6]=(resolver, data) => {\n\tresolver.f(data);\n\tresolver.p.s = 2;\n\tresolver.p.v = data;\n})($R[4],$R[5]=new Error(\"[SERVER_RENDER_ERROR] the reference twin's server error\"));$df(\"0\");function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById(\"pl-\"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!==\"pl-\"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,(_$HY.v=_$HY.v||{})[e]=n.hasAttribute(\"e\")?[...n.content.childNodes]:1,o.replaceWith(n.content),n.remove(),_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById(\"pl-\"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue===\"pl-\"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}function $dfe(e,t,k){(t=e.target)&&t.getAttribute&&!t._$dc&&(k=t.getAttribute(\"data-dfc\"))&&(t._$dc=1,$dfc(k))}document.addEventListener(\"load\",$dfe,!0);document.addEventListener(\"error\",$dfe,!0);</script><script>$R[6]($R[1],$R[5]);</script>"
4+
"rest": "<template id=\"0\" e></template><script>($R[6]=(resolver, data) => {\n\tresolver.f(data);\n\tresolver.p.s = 2;\n\tresolver.p.v = data;\n})($R[4],$R[5]=new Error(\"[SERVER_RENDER_ERROR] the reference twin's server error\"));$df(\"0\");function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById(\"pl-\"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!==\"pl-\"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,(_$HY.v=_$HY.v||{})[e]=n.hasAttribute(\"e\")?[...n.content.childNodes]:1,o.replaceWith(n.content),n.remove(),_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById(\"pl-\"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue===\"pl-\"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}function $dfe(e,t,k){(t=e.target)&&t.getAttribute&&!t._$dc&&(k=t.getAttribute(\"data-dfc\"))&&(t._$dc=1,$dfc(k))}document.addEventListener(\"load\",$dfe,!0);document.addEventListener(\"error\",$dfe,!0);</script><script>$R[6]($R[1],$R[5]);</script>"
55
}

0 commit comments

Comments
 (0)