Skip to content

Commit cfd33ea

Browse files
test(signals): pin the 3540 keyed-Show park re-derive at its target [1,2,2] as a known bug (#4417)
Co-authored-by: Cursor <[email protected]>
1 parent 9545058 commit cfd33ea

2 files changed

Lines changed: 28 additions & 32 deletions

File tree

‎packages/signals/tests/boundary-not-born-held-3540.test.ts‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ describe("Loading `on` beside a keyed Show around the boundary (#3540)", () => {
333333
["on", "committed", HELD]
334334
];
335335
for (const [form, key, midFlight] of matrix) {
336-
test(`${form} over ${key}: mid-flight ${midFlight === EARLY ? "reveals fallback early" : "holds"}`, async () => {
336+
// Known bug #4417: the park re-derive voids the provisional owner, so the same key mounts again ([1,3,3]). Target [1,2,2] via in-place re-derive (reader-seat S1).
337+
const it = form !== "on" && key === "latest" ? test.fails : test;
338+
it(`${form} over ${key}: mid-flight ${midFlight === EARLY ? "reveals fallback early" : "holds"}`, async () => {
337339
// `on` over committed warns LOADING_ON_OUTSIDE_HOLD (B reads data too).
338340
const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
339341
const t = build(form, key);
@@ -352,21 +354,17 @@ describe("Loading `on` beside a keyed Show around the boundary (#3540)", () => {
352354
expect(t.snapshot()).toBe("2|2|2");
353355
seen.push(t.mounts());
354356
// A keyed Show remounts at the key change — over `count()` once, at
355-
// the landing. Over `latest(count)` twice, mid-flight (design ruling
356-
// R-5, #4365): `latest()` opens no transaction for its verdict, so the
357-
// condition's first pass is the frame's — Show mounts A for key 2 in
358-
// the frame, which parks on data and holds that mount. The parked
359-
// flush re-runs the `latest()` reader once in the verdict lane and
360-
// Show mounts A again there: the lane's mount is the one shown (the
361-
// early fallback), the held frame's is discarded at the lane's reveal.
362-
// (Before R-5 the read opened the flush's transaction and seated the
363-
// pass in the lane at once: one mount, #3540 web.) Why 3: the parked
364-
// flush re-derives the pass that read `latest(count)` once, as a
365-
// verdict reader (D-2, A10), and a keyed Show whose condition is that
366-
// read mounts its branch on that re-derive. That is the cost of keying
367-
// a mount on a `latest()` read at a park, not a bug (maintainer ruling
368-
// on #4365). `on` never remounts.
369-
expect(seen).toEqual(form === "on" ? [0, 0, 0] : key === "latest" ? [1, 3, 3] : [1, 2, 2]);
357+
// the landing; over `latest(count)` once, mid-flight: `latest()` opens
358+
// no transaction for its verdict (R-5, #4365), so the condition's
359+
// first pass is the frame's — Show mounts A for key 2 in the frame,
360+
// which parks on data. The parked flush re-derives the pass that read
361+
// `latest(count)` once, as a verdict reader (D-2, A10); `latest()`
362+
// serves the staging on both runs, so the key is the same and the
363+
// one child stays mounted. Today the re-derive voids the provisional
364+
// owner and compares against the last COMMITTED `when`, so the same
365+
// key mounts again ([1, 3, 3]) — the known bug #4417, pinned above as
366+
// `test.fails` at its target. `on` never remounts.
367+
expect(seen).toEqual(form === "on" ? [0, 0, 0] : [1, 2, 2]);
370368
t.dispose();
371369
expect(warn).toHaveBeenCalledTimes(form === "on" && key === "committed" ? 1 : 0);
372370
warn.mockRestore();

‎packages/web/test/loading-on-keyed-boundary-3540.spec.tsx‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -127,32 +127,30 @@ describe("Loading `on` beside a keyed Show around the boundary; a boundary is ne
127127
// first landing, mid-flight, after the second landing]. Static and callback
128128
// children are re-evaluated by `Show` at the key change: one more mount,
129129
// mid-flight. `on` never remounts.
130-
// Over `latest(count)` that is two mounts mid-flight (design ruling R-5,
131-
// #4365): `latest()` opens no transaction for its verdict, so the
132-
// condition's first pass is the frame's — `Show` mounts A for key 2 in the
133-
// frame, and the frame parks on data, holding that mount. The parked flush
134-
// re-runs the `latest()` reader once in the verdict lane, and `Show` mounts
135-
// A again there: the lane's mount is the one shown (the early fallback),
136-
// and the held frame's is discarded at the lane's reveal. (Before R-5 the
137-
// read opened the flush's transaction and seated the pass in the lane at
138-
// once: one mount.) Why 3: the parked flush re-derives the pass that read
139-
// `latest(count)` once, as a verdict reader (D-2, A10), and a keyed `Show`
140-
// whose condition is that read mounts its branch on that re-derive. That is
141-
// the cost of keying a mount on a `latest()` read at a park, not a bug
142-
// (maintainer ruling on #4365).
130+
// Over `latest(count)` that one mount is mid-flight: `latest()` opens no
131+
// transaction for its verdict (R-5, #4365), so the condition's first pass
132+
// is the frame's — `Show` mounts A for key 2 in the frame, and the frame
133+
// parks on data. The parked flush re-derives the pass that read
134+
// `latest(count)` once, as a verdict reader (D-2, A10); `latest()` serves
135+
// the staging on both runs, so the key is the same and the one child stays
136+
// mounted. Today the re-derive voids the provisional owner and compares
137+
// against the last COMMITTED `when`, so the same key mounts again
138+
// ([1, 3, 3]) — the known bug #4417, pinned as `test.fails` at its target.
143139
// (A zero-arg function child is an accessor — evaluated once, not remounted
144140
// per key — and is deliberately not pinned here.)
145141
const matrix: Array<[Variant, string, [number, number, number], string[]]> = [
146-
["show-static-latest", EARLY, [1, 3, 3], []],
147-
["show-callback-latest", EARLY, [1, 3, 3], []],
142+
["show-static-latest", EARLY, [1, 2, 2], []],
143+
["show-callback-latest", EARLY, [1, 2, 2], []],
148144
["show-static-committed", HELD, [1, 2, 2], []],
149145
["show-callback-committed", HELD, [1, 2, 2], []],
150146
["on-committed", HELD, [0, 0, 0], ["LOADING_ON_OUTSIDE_HOLD"]],
151147
["on-latest", EARLY, [0, 0, 0], []]
152148
];
153149
for (const [variant, midFlight, expectedMounts, expectedCodes] of matrix) {
154150
const remounted = expectedMounts[1] > expectedMounts[0];
155-
test(`${variant}: mid-flight ${midFlight === EARLY ? "reveals fallback early" : "held"}, A ${
151+
// Known bug #4417: the park re-derive voids the provisional owner, so the same key mounts again ([1,3,3]). Target [1,2,2] via in-place re-derive (reader-seat S1).
152+
const it = variant.startsWith("show-") && variant.endsWith("-latest") ? test.fails : test;
153+
it(`${variant}: mid-flight ${midFlight === EARLY ? "reveals fallback early" : "held"}, A ${
156154
remounted ? "remounted" : "not remounted"
157155
} at the key change`, async () => {
158156
const { div, setCount, dispose, mounts } = setup(variant);

0 commit comments

Comments
 (0)