|
| 1 | +/** |
| 2 | + * @vitest-environment jsdom |
| 3 | + */ |
| 4 | +// async-gen rerun on rc.20, E3 (a derived store `createStore(d => { d.v = m() })` |
| 5 | +// reads like `m`): two liveness failures with one cause. The derive went |
| 6 | +// pending on m0's flight; the flight then settled (a rejection staged in its |
| 7 | +// transaction, or a re-ask that returned to the committed question) without |
| 8 | +// the derive re-running. The settle retired m0 from the derive, but the |
| 9 | +// store's readers wait on the derive itself (projection.ts `wakeFamily`), and |
| 10 | +// nothing retired that: `isPending` stayed true forever (F-9), and the staged |
| 11 | +// rejection's transaction never landed, so the error never showed (F-12). The |
| 12 | +// settle walk now settles the family with the derive (core |
| 13 | +// `settlePendingSource` -> projection.ts `familyStatus`), as a memo's |
| 14 | +// readers settle through its dependents. |
| 15 | +import { expect, test } from "vitest"; |
| 16 | +import { runScenario } from "./run.js"; |
| 17 | + |
| 18 | +const cases: Record<string, any> = { |
| 19 | + // [s0=2 m0=async(s0)] <span fx[m0()]>isPending(m0)</span> :: S5 m A(s0=0) s0=2 |
| 20 | + "isPending settles when the re-ask nets to the committed question": { |
| 21 | + signals: [2], |
| 22 | + memos: [{ async: true, deps: [{ src: { k: "s", i: 0 }, how: "plain" }], poison: null }], |
| 23 | + tree: { |
| 24 | + t: "leaf", |
| 25 | + text: [{ how: "pending", src: { k: "m", i: 0 } }], |
| 26 | + attrs: [{ how: "plain", src: { k: "m", i: 0 } }], |
| 27 | + grouped: true |
| 28 | + }, |
| 29 | + steps: [ |
| 30 | + { t: "settle", pick: 5 }, |
| 31 | + { t: "micro" }, |
| 32 | + { t: "action", s: 0, v: 0 }, |
| 33 | + { t: "write", s: 0, v: 2 } |
| 34 | + ] |
| 35 | + }, |
| 36 | + // [s0=2 s1=2 m0=async(s1 !%4=1)] <span>m0()</span> :: S4 m s1=0 |
| 37 | + "a refetch's rejection reaches the store's readers": { |
| 38 | + signals: [2, 2], |
| 39 | + memos: [{ async: true, deps: [{ src: { k: "s", i: 1 }, how: "plain" }], poison: 1 }], |
| 40 | + tree: { t: "leaf", text: [{ how: "plain", src: { k: "m", i: 0 } }], attrs: [], grouped: true }, |
| 41 | + steps: [{ t: "settle", pick: 4 }, { t: "micro" }, { t: "write", s: 1, v: 0 }] |
| 42 | + } |
| 43 | +}; |
| 44 | + |
| 45 | +for (const [name, sc] of Object.entries(cases)) |
| 46 | + test(`E3: ${name}`, async () => { |
| 47 | + const memo = await runScenario(sc, {}); |
| 48 | + const store = await runScenario(sc, { store: true }); |
| 49 | + expect(store.screens).toEqual(memo.screens); |
| 50 | + expect(store.final).toBe(memo.final); |
| 51 | + expect(store.findings).toEqual([]); |
| 52 | + }); |
0 commit comments