|
9 | 9 | import { describe, expect, test } from "vitest"; |
10 | 10 | import { createMemo, createSignal, Errored, flush, latest, Loading, Show } from "solid-js"; |
11 | 11 | import { render } from "../src/index.js"; |
| 12 | +import { runScenario } from "./async-gen/run.js"; |
| 13 | +import type { Scenario } from "./async-gen/scenario.js"; |
12 | 14 |
|
13 | 15 | const tick = async () => { |
14 | 16 | for (let i = 0; i < 5; i++) await Promise.resolve(); |
@@ -61,3 +63,45 @@ describe("a reader born in the flush that clears an upstream error (#4378)", () |
61 | 63 | dispose(); |
62 | 64 | }); |
63 | 65 | }); |
| 66 | + |
| 67 | +// The generator's E8 case at next @ 40cde2cd: the staging the hold built is |
| 68 | +// superseded at every frame node up the chain (the inner Errored, the root |
| 69 | +// Loading and Errored), each re-run from the heap outside its hold and back |
| 70 | +// to its committed fallback. |
| 71 | +test("the generator's E8 case: recreated readers under nested boundaries (#4378)", async () => { |
| 72 | + const sc: Scenario = { |
| 73 | + signals: [2, 3], |
| 74 | + memos: [ |
| 75 | + { async: false, deps: [{ src: { k: "s", i: 1 }, how: "latest" }], poison: 0 }, |
| 76 | + { async: true, deps: [{ src: { k: "m", i: 0 }, how: "plain" }], poison: 0 } |
| 77 | + ], |
| 78 | + tree: { |
| 79 | + t: "errored", |
| 80 | + child: { |
| 81 | + t: "leaf", |
| 82 | + text: [], |
| 83 | + attrs: [ |
| 84 | + { how: "plain", src: { k: "s", i: 1 } }, |
| 85 | + { how: "plain", src: { k: "m", i: 1 } } |
| 86 | + ], |
| 87 | + grouped: false |
| 88 | + } |
| 89 | + }, |
| 90 | + steps: [ |
| 91 | + { t: "settle", pick: 0 }, |
| 92 | + { t: "task" }, |
| 93 | + { t: "action", s: 1, v: 0 }, |
| 94 | + { t: "write", s: 1, v: 1 }, |
| 95 | + { t: "flush" }, |
| 96 | + { t: "action", s: 1, v: 0 }, |
| 97 | + { t: "write", s: 1, v: 2 }, |
| 98 | + { t: "settle", pick: 3 } |
| 99 | + ] |
| 100 | + } as Scenario; |
| 101 | + const kept = await runScenario(sc); |
| 102 | + const recreated = await runScenario(sc, { remount: true }); |
| 103 | + // Where nothing is in flight (the last step settles the last request). |
| 104 | + expect(recreated.screens.at(-1)).toBe("[E]"); |
| 105 | + expect(recreated.final).toBe(kept.final); |
| 106 | + expect(recreated.final).toBe("[E]"); |
| 107 | +}); |
0 commit comments