Commit 1d29f25
committed
Move fetch depth tracking into the store so it survives SSR hydration (#261)
A dynamic component position on a data-page parent lost its resolved
`component` moments after a server-side load of a nested child page,
collapsing the parent data page to a placeholder (admin) or nothing.
The depth-aware `path` request header requires a depth-0 resource to be
requested with the depth-0 route path, so the API can resolve the
position's `pageDataProperty` against the parent's page data. That lookup
was backed by in-memory Maps on FetchStatusManager, populated only by
`setManifestIrisByDepth`. On SSR the server built them and fetched
correctly, but the client hydrated the store while constructing a fresh
manager with empty maps — no manifest fetch runs client-side, so nothing
rebuilt them. Client-side re-fetches then fell back to `primaryFetchPath`
(the child route), whose static page has no page data, and the API
returned the position with `component: null`. Only depth-0 resources
broke: the fallback happens to be correct for depth 1.
Move the tracking into the fetcher store as `iriDepths`/`depthPaths`
(plain objects, so they serialise into the payload), derived by the
`setManifestIrisByDepth` action, with `registerIriDepth`/`resetIriDepths`
as store actions and the manager delegating. Single source of truth, so
the desync cannot recur. `registerIriDepth` is preserved intact —
deriving from `irisByDepth` alone would drop IRIs the manifest never
contained, and it was collateral here anyway (nested IRIs only register
when the parent's depth is known).
Reproduction: nested-page-hydration.spec.ts drives the real stores
through the SSR fetch, then simulates hydration with a new manager over
the same store, against a stub modelling the API's page-data resolution.
It asserts the outcome — the position still has its component — so it
fails whether the fallout is a placeholder or nothing.
Depth-tracking behaviour ported to the store's actions.spec.ts; the
manager spec now pins delegation.1 parent 689bc66 commit 1d29f25
9 files changed
Lines changed: 449 additions & 101 deletions
File tree
- src/runtime
- api/fetcher
- storage/stores/fetcher
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
292 | 292 | | |
293 | 293 | | |
294 | 294 | | |
| 295 | + | |
295 | 296 | | |
296 | 297 | | |
297 | 298 | | |
| |||
451 | 452 | | |
452 | 453 | | |
453 | 454 | | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
454 | 485 | | |
455 | 486 | | |
456 | 487 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
229 | 230 | | |
230 | 231 | | |
231 | 232 | | |
| |||
770 | 771 | | |
771 | 772 | | |
772 | 773 | | |
773 | | - | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
774 | 778 | | |
775 | 779 | | |
776 | | - | |
777 | | - | |
778 | 780 | | |
779 | 781 | | |
780 | 782 | | |
781 | 783 | | |
782 | | - | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
783 | 795 | | |
784 | 796 | | |
785 | 797 | | |
786 | 798 | | |
787 | 799 | | |
788 | 800 | | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | | - | |
809 | | - | |
810 | | - | |
| 801 | + | |
| 802 | + | |
811 | 803 | | |
812 | 804 | | |
813 | 805 | | |
814 | | - | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
| 806 | + | |
822 | 807 | | |
823 | | - | |
824 | 808 | | |
825 | 809 | | |
826 | 810 | | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
839 | 815 | | |
840 | 816 | | |
841 | | - | |
| 817 | + | |
842 | 818 | | |
843 | | - | |
| 819 | + | |
844 | 820 | | |
845 | 821 | | |
846 | 822 | | |
847 | | - | |
848 | | - | |
849 | | - | |
850 | | - | |
851 | | - | |
852 | | - | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
857 | | - | |
858 | | - | |
859 | | - | |
860 | 823 | | |
861 | | - | |
862 | | - | |
863 | | - | |
| 824 | + | |
864 | 825 | | |
865 | 826 | | |
866 | 827 | | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | 828 | | |
876 | | - | |
877 | | - | |
878 | | - | |
| 829 | + | |
879 | 830 | | |
880 | 831 | | |
881 | 832 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | | - | |
59 | | - | |
60 | 57 | | |
61 | 58 | | |
62 | 59 | | |
| |||
107 | 104 | | |
108 | 105 | | |
109 | 106 | | |
110 | | - | |
111 | | - | |
| 107 | + | |
112 | 108 | | |
113 | 109 | | |
114 | 110 | | |
| |||
380 | 376 | | |
381 | 377 | | |
382 | 378 | | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
| 379 | + | |
396 | 380 | | |
397 | 381 | | |
398 | 382 | | |
399 | 383 | | |
400 | | - | |
| 384 | + | |
401 | 385 | | |
402 | 386 | | |
403 | 387 | | |
404 | | - | |
| 388 | + | |
405 | 389 | | |
406 | 390 | | |
407 | 391 | | |
408 | | - | |
| 392 | + | |
409 | 393 | | |
410 | 394 | | |
411 | 395 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
191 | | - | |
| 191 | + | |
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
| |||
0 commit comments