@@ -666,77 +666,88 @@ function describePprShell(mode: "dev" | "build") {
666666 ) ;
667667 } ) ;
668668
669- // --- Negative contract: a loader WITHOUT loading() is not a hole . ---
670-
671- // /ppr-shell/no-hole has a loader but NO route-level loading( ): the BAKE
672- // lane (docs/design/loader-container-bake.md). The loader executes during
673- // capture; its settled container (the outer label) bakes into the prelude;
674- // the nested pendingData promise postpones at the consumer's own inner
675- // Suspense — a hole. On every HIT the snapshot's loader family overlays
676- // the recorded container onto the fresh run (outer label PINNED at its
677- // capture-time seq) while the nested promise stays live (inner seq
678- // advances per request). Runs on the real KV-backed CFCacheStore under
679- // workerd, so the loader-family snapshot round-trips the KV envelope .
680- test ( "no loading() (bake lane): HITs with the container baked+pinned and the nested promise live " , async ( {
669+ // --- Negative contract: no boundary above the reader = no shell . ---
670+
671+ // /ppr-shell/no-hole — CONTRACT CHANGE (streaming useLoader ): route
672+ // loaders are LIVE at capture unconditionally; the bake lane for
673+ // value-slot loaders is gone. This route's outer read has NO boundary
674+ // above it, so the masked loader root-postpones the capture and the
675+ // <body> sanity gate refuses the shell: ppr on a boundary-less route
676+ // degrades to runtime rendering (once-per-key eternal-MISS warning).
677+ // Axis 1 streams everything FRESH per request. Baking route data is
678+ // expressed via cache()/"use cache", never by omitting loading(). Runs
679+ // on the real KV-backed CFCacheStore under workerd .
680+ test ( "no loading() and no boundary above the reader: capture refuses, stays MISS, axis 1 streams fresh " , async ( {
681681 request,
682682 } ) => {
683683 const url = f . url ( "/ppr-shell/no-hole?probe=nohole" ) ;
684- await warmToHit ( request , url ) ;
685-
686- const { html } = await measureFirstChunk ( url ) ;
687- const { prelude, resumed } = splitPrelude ( html ) ;
688684
689- expect ( prelude ) . toMatch ( / S t r e a m e d o u t e r \d + / ) ;
690- expect ( prelude ) . toContain ( "Loading inner..." ) ;
691- expect ( prelude ) . not . toMatch ( / S t r e a m e d i n n e r \d + / ) ;
692- expect ( resumed ) . toMatch ( / S t r e a m e d i n n e r \d + / ) ;
693-
694- const second = await measureFirstChunk ( url ) ;
695685 const outerSeq = ( h : string ) =>
696686 Number ( h . match ( / S t r e a m e d o u t e r ( \d + ) / ) ?. [ 1 ] ) ;
697687 const innerSeq = ( h : string ) =>
698688 Number ( h . match ( / S t r e a m e d i n n e r ( \d + ) / ) ?. [ 1 ] ) ;
699- expect ( outerSeq ( second . html ) ) . toBe ( outerSeq ( html ) ) ;
700- expect ( innerSeq ( second . html ) ) . toBeGreaterThan ( innerSeq ( html ) ! ) ;
689+
690+ let firstHtml = "" ;
691+ for ( let i = 0 ; i < 3 ; i ++ ) {
692+ const res = await request . get ( url , { headers : HTML_HEADERS } ) ;
693+ expect ( res . status ( ) ) . toBe ( 200 ) ;
694+ expect (
695+ res . headers ( ) [ "x-rango-shell" ] ,
696+ `request #${ i } must stay MISS (no boundary above the reader)` ,
697+ ) . toBe ( "MISS" ) ;
698+ const html = await res . text ( ) ;
699+ expect ( html ) . toMatch ( / S t r e a m e d o u t e r \d + / ) ;
700+ expect ( html ) . toContain ( "Loading inner..." ) ;
701+ expect ( html ) . toMatch ( / S t r e a m e d i n n e r \d + / ) ;
702+ if ( i === 0 ) firstHtml = html ;
703+ if ( i < 2 ) await new Promise ( ( r ) => setTimeout ( r , 350 ) ) ;
704+ }
705+
706+ // Liveness: nothing pinned anywhere — both values advance per request.
707+ const last = await request . get ( url , { headers : HTML_HEADERS } ) ;
708+ const lastHtml = await last . text ( ) ;
709+ expect ( outerSeq ( lastHtml ) ) . toBeGreaterThan ( outerSeq ( firstHtml ) ! ) ;
710+ expect ( innerSeq ( lastHtml ) ) . toBeGreaterThan ( innerSeq ( firstHtml ) ! ) ;
701711 } ) ;
702712
703- // /ppr-shell/settled: nested-promise SHAPE is the liveness declaration.
704- // A bake-lane loader's nested promise that is ALREADY RESOLVED at
705- // container return previously won the capture window and its VALUE was
706- // snapshot-pinned — every HIT then served the capture-time value to every
707- // visitor (found live: a storefront basket, with the capturing session's
708- // identifiers, frozen into the shared shell and served to anonymous
709- // requests). Nested thenables are now MASKED at capture regardless of
710- // settle timing: the consumer's own Suspense postpones (its fallback bakes
711- // as the hole) and every HIT streams the FRESH value. The consumer still
712- // receives a real promise, so the original #438 regression stays
713- // impossible. Runs on the real KV-backed CFCacheStore under workerd, so
714- // the hole-marker record round-trips the KV envelope.
715- test ( "bake lane, nested promise settled inside the window: holes anyway — outer pins, nested value stays FRESH per request" , async ( {
713+ // /ppr-shell/settled — CONTRACT CHANGE (streaming useLoader): the bake
714+ // lane for value-slot loaders is gone, so settle timing can no longer pin
715+ // ANY value — the whole loader is masked at capture, and this route's
716+ // outer read has no boundary above it, so the capture refuses and the
717+ // route stays MISS. The cross-session bake leak this fixture guarded
718+ // against (a storefront basket frozen into the shared shell) is now
719+ // impossible by construction — nothing from a value-slot loader can
720+ // enter a shell. Axis 1 serves everything fresh; hydration stays clean
721+ // and use(data.fast) still receives a real promise (#438). Runs on the
722+ // real KV-backed CFCacheStore under workerd.
723+ test ( "nested promise settled inside the window: stays MISS, everything fresh per request, hydration clean" , async ( {
716724 request,
717725 page,
718726 } ) => {
719727 const url = f . url ( "/ppr-shell/settled?probe=settled" ) ;
720- await warmToHit ( request , url ) ;
721728
722- const { html } = await measureFirstChunk ( url ) ;
723729 const outerSeq = ( h : string ) =>
724730 Number ( h . match ( / S e t t l e d o u t e r ( \d + ) / ) ?. [ 1 ] ) ;
725731 const fastSeq = ( h : string ) => Number ( h . match ( / S e t t l e d f a s t ( \d + ) / ) ?. [ 1 ] ) ;
726- // Parity: the outer (non-promise) container material is snapshot-pinned.
732+
733+ const first = await request . get ( url , { headers : HTML_HEADERS } ) ;
734+ expect ( first . headers ( ) [ "x-rango-shell" ] ) . toBe ( "MISS" ) ;
735+ const html = await first . text ( ) ;
727736 expect ( outerSeq ( html ) ) . toBeGreaterThan ( 0 ) ;
728- // The frozen prelude holds the consumer's Suspense fallback, never a
729- // pinned nested value — the nested promise holes by declaration.
730- const { prelude } = splitPrelude ( html ) ;
731- expect ( prelude ) . toContain ( "fast pending..." ) ;
732- expect ( prelude ) . not . toMatch ( / S e t t l e d f a s t \d + / ) ;
733- // Liveness: the nested value is a FRESH execution's and advances per HIT.
734- expect ( fastSeq ( html ) ) . toBeGreaterThan ( outerSeq ( html ) ! ) ;
735- const second = await measureFirstChunk ( url ) ;
736- expect ( outerSeq ( second . html ) ) . toBe ( outerSeq ( html ) ) ;
737- expect ( fastSeq ( second . html ) ) . toBeGreaterThan ( fastSeq ( html ) ! ) ;
737+ expect ( html ) . toMatch ( / S e t t l e d f a s t \d + / ) ;
738738
739- // Browser: the HIT hydrates cleanly — use(data.fast) still receives a
739+ await new Promise ( ( r ) => setTimeout ( r , 350 ) ) ;
740+ const second = await request . get ( url , { headers : HTML_HEADERS } ) ;
741+ expect (
742+ second . headers ( ) [ "x-rango-shell" ] ,
743+ "no boundary above the reader — capture must keep refusing" ,
744+ ) . toBe ( "MISS" ) ;
745+ const secondHtml = await second . text ( ) ;
746+ // Liveness: nothing pinned — both values advance per request.
747+ expect ( outerSeq ( secondHtml ) ) . toBeGreaterThan ( outerSeq ( html ) ! ) ;
748+ expect ( fastSeq ( secondHtml ) ) . toBeGreaterThan ( fastSeq ( html ) ! ) ;
749+
750+ // Browser: axis 1 hydrates cleanly — use(data.fast) still receives a
740751 // real promise (the fresh one), so #438 cannot recur.
741752 using __ = guardHydrationErrors ( page ) ;
742753 await page . goto ( url ) ;
@@ -846,52 +857,39 @@ function describePprShell(mode: "dev" | "build") {
846857 expect ( prelude ) . toContain ( "Bare home static content" ) ;
847858 } ) ;
848859
849- // /ppr-shell/bake-slow: the PIN-FIRST optimization (loader-cache.ts
850- // `if (!recorded.holes)`) on the real KV-backed CFCacheStore under workerd.
851- // The layout registers a 600ms bake-lane loader (no loading() on the
852- // layout) returning a plain HOLE-FREE container. Its container bakes into
853- // the snapshot's loader family hole-free, so on a HIT the payload resolves
854- // the loaderData from the PIN immediately instead of gating on the fresh
855- // 600ms run (which still executes ungated for side effects). The child keeps
856- // a fast ~30ms price hole behind loading() so a real shell captures. Two
857- // guarantees in one: the served label is pinned (frozen across HITs, not the
858- // advancing fresh seq) AND the pin makes the full HIT response beat the
859- // 600ms fresh run.
860- test ( "pin-first bake lane: a HIT serves the pinned 600ms container fast and frozen across HITs" , async ( {
860+ // /ppr-shell/bake-slow — CONTRACT CHANGE (streaming useLoader): the
861+ // pin-first bake optimization is gone with the bake lane itself. The
862+ // layout's 600ms loader is masked at capture like every value-slot
863+ // loader; its reader sits inside the child route's loading() boundary,
864+ // so the shell still captures (chrome baked, the route area one live
865+ // hole) and every HIT re-runs the loader FRESH — the label ADVANCES
866+ // across HITs instead of freezing. The full HIT body now gates on the
867+ // real 600ms run; a route wanting the old fast+frozen behavior expresses
868+ // it with cache()/"use cache". Runs on the real KV-backed CFCacheStore
869+ // under workerd.
870+ test ( "slow layout loader under the child's loading(): HITs with the label LIVE per request (no pin)" , async ( {
861871 request,
862872 } ) => {
863873 const url = f . url ( "/ppr-shell/bake-slow?probe=bakeslow" ) ;
864874 await warmToHit ( request , url ) ;
865875
866- // request.get buffers the WHOLE body, so elapsed covers stream
867- // completion. Without pin-first the payload gates on the fresh 600ms bake
868- // run (elapsed >= 600ms); pinned, the recorded container resolves
869- // immediately and only the ~30ms live hole remains — the 400ms bound
870- // leaves a 200ms+ margin for CI noise either side.
871- const start = Date . now ( ) ;
872876 const res = await request . get ( url , { headers : HTML_HEADERS } ) ;
873- const elapsed = Date . now ( ) - start ;
874877 expect ( res . status ( ) ) . toBe ( 200 ) ;
875878 expect ( res . headers ( ) [ "x-rango-shell" ] ) . toBe ( "HIT" ) ;
876879 const html = await res . text ( ) ;
877880
878- // The pinned bake label rides the HIT body beside the live hole content.
879- const captured = / b a k e - \d + / . exec ( html ) ?. [ 0 ] ;
880- expect ( captured , "the pinned bake label rides the HIT body" ) . toBeTruthy ( ) ;
881+ // The fresh bake label rides the HIT body beside the live hole content.
882+ const captured = / b a k e - ( \d + ) / . exec ( html ) ;
883+ expect ( captured , "the bake label rides the HIT body" ) . toBeTruthy ( ) ;
881884 expect ( html ) . toContain ( "Live price:" ) ;
882885
883- expect (
884- elapsed ,
885- `HIT full-response ${ elapsed } ms must beat the 600ms fresh bake run` ,
886- ) . toBeLessThan ( 400 ) ;
887-
888- // Frozen: a second HIT serves the SAME captured label (the pin, not the
889- // fresh seq that keeps advancing in the background) while the price hole
890- // stays live.
886+ // LIVE: a second HIT serves an ADVANCED label — the loader re-ran
887+ // fresh; nothing from a value-slot loader is pinned into the shell.
891888 const second = await request . get ( url , { headers : HTML_HEADERS } ) ;
892889 expect ( second . headers ( ) [ "x-rango-shell" ] ) . toBe ( "HIT" ) ;
893890 const secondHtml = await second . text ( ) ;
894- expect ( / b a k e - \d + / . exec ( secondHtml ) ?. [ 0 ] ) . toBe ( captured ) ;
891+ const secondLabel = / b a k e - ( \d + ) / . exec ( secondHtml ) ;
892+ expect ( Number ( secondLabel ! [ 1 ] ) ) . toBeGreaterThan ( Number ( captured ! [ 1 ] ) ) ;
895893 expect ( secondHtml ) . toContain ( "Live price:" ) ;
896894 } ) ;
897895
0 commit comments