diff --git a/.changeset/lane-hold-staged-error-4841.md b/.changeset/lane-hold-staged-error-4841.md
new file mode 100644
index 0000000000..a1432bf537
--- /dev/null
+++ b/.changeset/lane-hold-staged-error-4841.md
@@ -0,0 +1,5 @@
+---
+"@solidjs/signals": patch
+---
+
+A guess lane no longer shows an error that another action still holds. `` waits for the hold, as it does when nothing reads a guess, instead of flipping early and then recovering over the previous question's answer (#4841).
diff --git a/packages/signals/docs/RULES-INDEX.md b/packages/signals/docs/RULES-INDEX.md
index 08c3222bef..5b7bad23c7 100644
--- a/packages/signals/docs/RULES-INDEX.md
+++ b/packages/signals/docs/RULES-INDEX.md
@@ -51,9 +51,9 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
| id | status | defined | cited in src | cited in tests | statement (at definition) |
|---|---|---|---|---|---|
-| F-1 | live | `docs/RULES-FUNDAMENTALS.md:45` | boundaries.ts×3 async.ts×1 core.ts×1 effect.ts×1 guesses.ts×1 lanes.ts×8 scheduler.ts×2 seat.ts×2 verdict.ts×6 optimistic.ts×4 | async-reads-ahead-matrix.test.ts×2 async-reads-ahead-second-write.test.ts×1 blank-rows-4831.test.ts×1 deep-snapshot-after-action.test.ts×7 errored-held-mount-staged-error-4480.test.ts×1 errored-list-recovery-held-4526.test.ts×1 errored-recovery-fresh-loading-4627.test.ts×2 errored-recovery-stale-memo-4592.test.ts×1 ispending-async-derivation-4677.test.ts×3 ispending-memo-wrapped-asker-4778.test.ts×1 landing-frame-verdict-memo.test.ts×1 latest-beside-staged-read-4365.test.ts×1 latest-derived-held-error-guess-lane-4106.test.ts×1 latest-snapshot-scope-4570.test.ts×1 loading-on-latest-fallback-4337.test.ts×1 loading-reveal-held-outside-4593.test.ts×1 midflight-memo-over-reask-4504.test.ts×1 optimistic-guess-beside-reask-4824.test.ts×2 optimistic-guess-entangled-async-4577.test.ts×2 optimistic-guess-memo-binding-4561.test.ts×4 optimistic-guess-over-staged-error-4751.test.ts×1 optimistic-guess-parked-question-4559.test.ts×1 optimistic-guess-second-async-memo-4577.test.ts×1 optimistic-guess-split-bindings-4536.test.ts×1 optimistic-held-error-untracked-read-4489.test.ts×1 optimistic-lane-seam-loop-4643.test.ts×2 optimistic-list-push-filter-push-4642.test.ts×2 optimistic-outside-reask-4690.test.ts×2 optimistic-question-change-4336.test.ts×3 optimistic-refresh-late-shared-memo-4576.test.ts×1 optimistic-shared-effect-question-4536.test.ts×1 projection-chain-lane-4762.test.ts×1 repark-drops-unreached-source-4541.test.ts×1 switch-under-guess-holds.test.ts×1 tracked-effect-staged-dep-4606-4607.test.ts×1 unread-derive-midflight-mount-4491.test.ts×1 verdict-memo-flight-no-reask.test.ts×1 verdict-memo-under-held-memo-4050.test.ts×1 verdict-probe-committed-4648.test.ts×2 verdict-probe-landing-4648.test.ts×1 verdict-seat-merged-lane-4427.test.ts×1 | The screen is whole |
+| F-1 | live | `docs/RULES-FUNDAMENTALS.md:45` | boundaries.ts×3 async.ts×1 core.ts×1 effect.ts×1 guesses.ts×1 lanes.ts×8 scheduler.ts×2 seat.ts×2 verdict.ts×7 optimistic.ts×4 | async-reads-ahead-matrix.test.ts×2 async-reads-ahead-second-write.test.ts×1 blank-rows-4831.test.ts×1 deep-snapshot-after-action.test.ts×7 errored-held-mount-staged-error-4480.test.ts×1 errored-list-recovery-held-4526.test.ts×1 errored-recovery-fresh-loading-4627.test.ts×2 errored-recovery-stale-memo-4592.test.ts×1 ispending-async-derivation-4677.test.ts×3 ispending-memo-wrapped-asker-4778.test.ts×1 landing-frame-verdict-memo.test.ts×1 latest-beside-staged-read-4365.test.ts×1 latest-derived-held-error-guess-lane-4106.test.ts×1 latest-snapshot-scope-4570.test.ts×1 loading-on-latest-fallback-4337.test.ts×1 loading-reveal-held-outside-4593.test.ts×1 midflight-memo-over-reask-4504.test.ts×1 optimistic-guess-beside-reask-4824.test.ts×2 optimistic-guess-entangled-async-4577.test.ts×2 optimistic-guess-memo-binding-4561.test.ts×4 optimistic-guess-over-staged-error-4751.test.ts×1 optimistic-guess-parked-question-4559.test.ts×1 optimistic-guess-second-async-memo-4577.test.ts×1 optimistic-guess-split-bindings-4536.test.ts×1 optimistic-held-error-untracked-read-4489.test.ts×1 optimistic-lane-seam-loop-4643.test.ts×2 optimistic-list-push-filter-push-4642.test.ts×2 optimistic-outside-reask-4690.test.ts×2 optimistic-question-change-4336.test.ts×3 optimistic-refresh-late-shared-memo-4576.test.ts×1 optimistic-shared-effect-question-4536.test.ts×1 projection-chain-lane-4762.test.ts×1 repark-drops-unreached-source-4541.test.ts×1 switch-under-guess-holds.test.ts×1 tracked-effect-staged-dep-4606-4607.test.ts×1 unread-derive-midflight-mount-4491.test.ts×1 verdict-memo-flight-no-reask.test.ts×1 verdict-memo-under-held-memo-4050.test.ts×1 verdict-probe-committed-4648.test.ts×2 verdict-probe-landing-4648.test.ts×1 verdict-seat-merged-lane-4427.test.ts×1 | The screen is whole |
| F-2 | live | `docs/RULES-FUNDAMENTALS.md:53` | async.ts×1 core.ts×2 lanes.ts×5 scheduler.ts×1 seat.ts×3 verdict.ts×3 optimistic.ts×1 projection.ts×1 store.ts×1 | async-reads-ahead-edges.test.ts×2 async-reads-ahead-matrix.test.ts×3 async-reads-ahead-second-write.test.ts×1 direction-rule-probe.test.ts×1 error-is-an-answer.test.ts×1 errored-fallback-verdict-memo-reset.test.ts×1 errored-held-mount-staged-error-4480.test.ts×2 first-load-superseded-answer-4569.test.ts×2 lane-unshown-leaf-4338.test.ts×1 loading-on-latest-fallback-4337.test.ts×2 loading-reveal-held-outside-4593.test.ts×1 midflight-memo-over-reask-4504.test.ts×2 optimistic-held-write-leak.test.ts×1 optimistic-nested-action-refresh-4576.test.ts×1 optimistic-question-change-4336.test.ts×1 optimistic-refresh-late-shared-memo-4576.test.ts×1 settle-diamond-revisit.test.ts×1 switch-under-guess-holds.test.ts×1 try-catch-reactive-read.test.ts×1 unread-derive-midflight-mount-4491.test.ts×2 verdict-memo-flight-no-reask.test.ts×1 verdict-probe-committed-4648.test.ts×1 | A change that needs async to be shown is held; the screen keeps what it showed |
-| F-3 | live | `docs/RULES-FUNDAMENTALS.md:61` | boundaries.ts×1 lanes.ts×1 verdict.ts×2 | errored-heal-disposed-reader-4373.test.ts×1 errored-heal-memo-reader-4644.test.ts×1 errored-memo-over-output-held-reject-4640.test.ts×1 lane-dissolve-disposed-member-4613.test.ts×2 loading-on-errorboundary-through-4639.test.ts×1 | A reader holds only while it is the display |
+| F-3 | live | `docs/RULES-FUNDAMENTALS.md:61` | boundaries.ts×1 lanes.ts×1 verdict.ts×2 | errored-heal-disposed-reader-4373.test.ts×1 errored-heal-memo-reader-4644.test.ts×1 errored-memo-over-output-held-reject-4640.test.ts×1 lane-dissolve-disposed-member-4613.test.ts×2 lane-hold-staged-error-4841.test.ts×1 loading-on-errorboundary-through-4639.test.ts×1 | A reader holds only while it is the display |
| F-4 | live | `docs/RULES-FUNDAMENTALS.md:69` | boundaries.ts×3 core.ts×1 lanes.ts×1 | derived-store-recovery-wake.test.ts×1 error-is-an-answer.test.ts×1 errored-memo-over-output-held-reject-4640.test.ts×1 errored-recovery-fresh-loading-4627.test.ts×3 errored-recovery-stale-memo-4592.test.ts×1 issue-3800-repro.test.ts×2 latest-memo-inline-parity.test.ts×1 loading-on-errorboundary-sibling-4638.test.ts×1 loading-on-errorboundary-through-4639.test.ts×1 loading-on-latest-fallback-4337.test.ts×1 | An armed boundary catches: what is pending under it holds nothing outside it |
| F-5 | live | `docs/RULES-FUNDAMENTALS.md:77` | — | loading-on-errorboundary-sibling-4638.test.ts×1 loading-on-held-change-4605.test.ts×2 loading-reveal-held-outside-4593.test.ts×1 | A disarmed boundary forwards: it keeps its content and holds like any reader, until `on` arms it again |
| F-6 | live | `docs/RULES-FUNDAMENTALS.md:85` | boundaries.ts×1 constants.ts×2 core.ts×3 effect.ts×1 lanes.ts×10 scheduler.ts×4 seat.ts×2 verdict.ts×5 optimistic.ts×4 projection.ts×1 store.ts×3 | async-reads-ahead-edges.test.ts×1 async-reads-ahead-matrix.test.ts×2 async-reads-ahead-second-write.test.ts×1 derived-store-lane-derive.test.ts×1 error-is-an-answer.test.ts×1 gc.test.ts×1 ispending-async-derivation-4677.test.ts×3 ispending-memo-parked-seam-4439.test.ts×1 ispending-memo-wrapped-asker-4778.test.ts×2 latest-beside-staged-read-4365.test.ts×1 latest-derived-held-error-4106.test.ts×1 latest-derived-sync-error-4377.test.ts×1 latest-first-one-pass-4402.test.ts×1 latest-memo-inline-parity.test.ts×3 latest-stale-branch-hold-4661.test.ts×2 latest-two-readers-one-ask-4393.test.ts×5 loading-on-latest-fallback-4337.test.ts×1 optimistic-guess-beside-reask-4824.test.ts×1 optimistic-held-write-leak.test.ts×1 optimistic-layered-filter-4336.test.ts×1 optimistic-outside-reask-4690.test.ts×2 optimistic-question-change-4336.test.ts×6 optimistic-second-guess-reask-4629.test.ts×1 optimistic-second-log-guess-4666.test.ts×1 projection-lane-length-4631.test.ts×1 projection-second-guess-4629.test.ts×1 rejection-beside-ispending-3957.test.ts×1 derived-latest-confirmed-key.test.ts×1 derived-store-heal-4451.test.ts×1 unread-derive-midflight-mount-4491.test.ts×2 verdict-memo-after-staged-read.test.ts×1 verdict-memo-flight-no-reask.test.ts×7 verdict-memo-held-branch-4544.test.ts×3 verdict-memo-under-held-memo-4050.test.ts×1 verdict-read-order.test.ts×1 | Display-ahead readers show now and never hold the change they read ahead of; their own async holds them, in their own lane |
@@ -104,7 +104,7 @@ Status legend: **live** stated and standing · **ruled** carries an explicit rul
| D-38 | live | `docs/RULES-DERIVED.md:245` | — | errored-reader-4486.test.ts×1 | Effect error phases; a comparator throw is a compute error; an escaping error halts |
| D-39 | live | `docs/RULES-DERIVED.md:253` | boundaries.ts×9 core.ts×1 lanes.ts×1 scheduler.ts×3 types.ts×1 store.ts×1 | derived-store-recovery-wake.test.ts×1 error-boundary-superseded-staged-error-4527.test.ts×1 error-is-an-answer.test.ts×2 error-staged-recovery.test.ts×1 errored-heal-memo-reader-4644.test.ts×2 errored-list-recovery-held-4526.test.ts×1 errored-memo-over-output-held-reject-4640.test.ts×1 errored-over-rearmed-loading-4384.test.ts×1 errored-reader-4486.test.ts×3 errored-recovery-fresh-loading-4627.test.ts×2 errored-recovery-stale-memo-4592.test.ts×2 errored-recovery-wedge-4403-4404-4405.test.ts×3 latest-memo-inline-parity.test.ts×2 latest-uninitialized-over-latest-4362.test.ts×1 createProjection.async.test.ts×1 derived-store-heal-4451.test.ts×1 | An error fallback is the display; it stays until a new answer replaces the error |
| D-40 | live | `docs/RULES-DERIVED.md:297` | constants.ts×1 core.ts×1 deferred.ts×2 signals.ts×1 | create-deferred-3710.test.ts×1 create-deferred.test.ts×1 | A deferred source lags its readers and never leads them |
-| D-41 | live | `docs/RULES-DERIVED.md:257` | boundaries.ts×5 async.ts×5 constants.ts×1 core.ts×12 lanes.ts×1 scheduler.ts×4 seat.ts×10 types.ts×1 verdict.ts×4 signals.ts×1 projection.ts×3 store.ts×2 | derived-store-error-delivered-once.test.ts×2 derived-store-recovery-wake.test.ts×1 error-boundary-superseded-staged-error-4527.test.ts×3 error-is-an-answer.test.ts×3 error-staged-recovery.test.ts×1 errored-held-mount-staged-error-4480.test.ts×3 errored-latest-obsolete-flight-4568.test.ts×1 errored-list-recovery-held-4526.test.ts×2 errored-memo-over-output-held-reject-4640.test.ts×1 errored-reader-4486.test.ts×1 errored-recovery-fresh-loading-4627.test.ts×4 errored-recovery-wedge-4403-4404-4405.test.ts×7 errored-staged-source-4364.test.ts×1 held-sync-throw-4109.test.ts×2 hold-recovers-landing-reruns-4469.test.ts×3 lane-correction-staged-error-4748.test.ts×1 latest-beside-staged-read-4365.test.ts×1 latest-derived-held-error-4106.test.ts×1 latest-derived-held-error-guess-lane-4106.test.ts×1 latest-derived-sync-error-4377.test.ts×2 loading-reveal-held-outside-4593.test.ts×1 optimistic-guess-over-staged-error-4751.test.ts×1 optimistic-held-error-untracked-read-4489.test.ts×3 settle-diamond-revisit.test.ts×1 staged-error-derivation.test.ts×1 staged-error-rerun-4109.test.ts×1 staged-error-through-async-memo-4640.test.ts×1 writable-memo-write-clears-error-4110.test.ts×1 | An error is an answer: it ends the wait like a value, and it shows when a value would |
+| D-41 | live | `docs/RULES-DERIVED.md:257` | boundaries.ts×5 async.ts×5 constants.ts×1 core.ts×12 lanes.ts×1 scheduler.ts×4 seat.ts×10 types.ts×1 verdict.ts×4 signals.ts×1 projection.ts×3 store.ts×2 | derived-store-error-delivered-once.test.ts×2 derived-store-recovery-wake.test.ts×1 error-boundary-superseded-staged-error-4527.test.ts×3 error-is-an-answer.test.ts×3 error-staged-recovery.test.ts×1 errored-held-mount-staged-error-4480.test.ts×3 errored-latest-obsolete-flight-4568.test.ts×1 errored-list-recovery-held-4526.test.ts×2 errored-memo-over-output-held-reject-4640.test.ts×1 errored-reader-4486.test.ts×1 errored-recovery-fresh-loading-4627.test.ts×4 errored-recovery-wedge-4403-4404-4405.test.ts×7 errored-staged-source-4364.test.ts×1 held-sync-throw-4109.test.ts×2 hold-recovers-landing-reruns-4469.test.ts×3 lane-correction-staged-error-4748.test.ts×1 lane-hold-staged-error-4841.test.ts×1 latest-beside-staged-read-4365.test.ts×1 latest-derived-held-error-4106.test.ts×1 latest-derived-held-error-guess-lane-4106.test.ts×1 latest-derived-sync-error-4377.test.ts×2 loading-reveal-held-outside-4593.test.ts×1 optimistic-guess-over-staged-error-4751.test.ts×1 optimistic-held-error-untracked-read-4489.test.ts×3 settle-diamond-revisit.test.ts×1 staged-error-derivation.test.ts×1 staged-error-rerun-4109.test.ts×1 staged-error-through-async-memo-4640.test.ts×1 writable-memo-write-clears-error-4110.test.ts×1 | An error is an answer: it ends the wait like a value, and it shows when a value would |
| D-42 | live | `docs/RULES-DERIVED.md:279` | boundaries.ts×2 async.ts×3 core.ts×5 dev.ts×1 effect.ts×2 owner.ts×1 verdict.ts×1 index.ts×1 signals.ts×1 | caught-reactive-read-diagnostic.test.ts×1 errored-reader-4486.test.ts×2 try-catch-reactive-read.test.ts×2 | A reactive read is not an `await`: `try/catch` around it is not a channel |
## A — spec propositions
diff --git a/packages/signals/src/core/verdict.ts b/packages/signals/src/core/verdict.ts
index 762823d1b6..93004dbe3e 100644
--- a/packages/signals/src/core/verdict.ts
+++ b/packages/signals/src/core/verdict.ts
@@ -861,14 +861,16 @@ function stageMark(node: Computed, el: Computed): void {
// the boundary that caught it, and the commit halted (#4640).
// A lane reader of a guess in its own lane reads the guess: the truth
// staged beneath it is the hold's, not the lane's display (F-11, D-34),
- // and the lane's seam would publish it now (D-41, #4751).
+ // and the lane's seam would publish it now (D-41, #4751). Nor does it
+ // carry a truth's staging: that is the hold's too, shown at its reveal —
+ // published by the lane, `` flipped ahead of the hold and then
+ // recovered over the previous question's committed answer (F-1, #4841).
for (let d = node._deps; d; d = d._nextDep)
if (
d._dep._config & CONFIG_STAGED_ERROR &&
!(
- d._dep._config & CONFIG_GUESS &&
node._x?._transaction?._lane &&
- d._dep._x!._transaction === node._x._transaction
+ (!(d._dep._config & CONFIG_GUESS) || d._dep._x!._transaction === node._x._transaction)
)
) {
node._pendingValue = el._pendingValue;
diff --git a/packages/signals/tests/lane-hold-staged-error-4841.test.ts b/packages/signals/tests/lane-hold-staged-error-4841.test.ts
new file mode 100644
index 0000000000..c2397a7fec
--- /dev/null
+++ b/packages/signals/tests/lane-hold-staged-error-4841.test.ts
@@ -0,0 +1,164 @@
+// #4841: a detail memo keyed on a selection fails while other actions are
+// out; the heading memo reads the detail and a `createOptimistic` rename
+// guess. The failure lands on a node an entangled action holds, so it is
+// staged (D-41), and the settle walk marked every derivation of it — the
+// heading too, a member of the rename's guess lane. That lane had shown and
+// was not held, so its seam published the hold's error at once: ``
+// flipped ahead of the hold, and when the re-ask's answer landed (still
+// held) the boundary recovered in the lane over the committed detail of the
+// previous selection (`#3 Alpha (detail of #4)`). A lane reader carries a
+// staged error only from a guess of another lane: a truth's staging is the
+// hold's, shown at its reveal. Reading the guess no longer changes what shows
+// (the plain heading never flipped). The DOM version is
+// packages/web/test/failed-reask-stale-detail-4841.spec.tsx.
+import { test, expect } from "vitest";
+import {
+ action,
+ createErrorBoundary,
+ createLoadingBoundary,
+ createMemo,
+ createOptimistic,
+ createRenderEffect,
+ createRoot,
+ createSignal,
+ flush,
+ refresh
+} from "../src/index.js";
+
+const tick = async () => {
+ for (let i = 0; i < 4; i++) {
+ await new Promise(r => setTimeout(r, 0));
+ flush();
+ }
+};
+
+async function run(readGuess: boolean) {
+ const asks: { key: string; p: Promise; res: (v: any) => void; rej: (e: any) => void }[] = [];
+ // One flight per key while it is out.
+ const ask = (key: string) => {
+ const o = asks.find(a => a.key === key);
+ if (o) return o.p;
+ let res: any, rej: any;
+ const p = new Promise((a, b) => ((res = a), (rej = b)));
+ asks.push({ key, p, res, rej });
+ return p;
+ };
+ const pick = (key: string) => {
+ const i = asks.findIndex(a => a.key === key);
+ if (i < 0) throw new Error("no ask " + key + " in " + asks.map(a => a.key));
+ return asks.splice(i, 1)[0];
+ };
+ const frames: string[] = [];
+ let screen = "";
+ let select!: (id: number) => void;
+ let rename!: (id: number, title: string) => void;
+ let close!: (id: number) => void;
+ let dispose!: () => void;
+ createRoot(d => {
+ dispose = d;
+ const [selected, setSelected] = createSignal(null);
+ const [renaming, guessRename] = createOptimistic<{ id: number; title: string }[]>(() => []);
+ const [, guessClose] = createOptimistic(() => []);
+ const list = createMemo(() => ask("list"));
+ const answer = createMemo(() => (selected() != null ? ask(`detail:${selected()}`) : undefined));
+ const detail = createMemo(() => (selected() == null ? null : answer()));
+ const heading = createMemo(() => {
+ const d: any = detail();
+ if (d == null) return "";
+ return readGuess
+ ? renaming().reduce((t, r) => (r.id === d.id ? r.title : t), d.title)
+ : d.title;
+ });
+ select = action(function* (id: number) {
+ setSelected(id);
+ });
+ rename = action(function* (id: number, title: string) {
+ guessRename(rs => [...rs, { id, title }]);
+ yield ask(`rename:${id}`);
+ refresh(list);
+ refresh(answer);
+ refresh(detail);
+ });
+ close = action(function* (id: number) {
+ guessClose(cs => [...cs, id]);
+ yield ask(`close:${id}`);
+ refresh(list);
+ });
+ //
+ // #{selected()} {heading()} (detail of #{detail()?.id})
+ const shown = createMemo(() => selected() != null);
+ const view = createMemo(() =>
+ shown()
+ ? createLoadingBoundary(
+ () =>
+ createErrorBoundary(
+ () => {
+ // One binding per hole, as the compiled template inserts them.
+ const holes = ["", "", ""];
+ const h2 = {
+ get text() {
+ return `#${holes[0]} ${holes[1]} (detail of #${holes[2]})`;
+ }
+ };
+ createRenderEffect(selected, v => void (holes[0] = String(v)));
+ createRenderEffect(heading, v => void (holes[1] = v));
+ createRenderEffect(
+ () => (detail() as any)?.id,
+ v => void (holes[2] = String(v))
+ );
+ return h2;
+ },
+ e => ({ text: `detail error: ${(e() as any)?.message}` })
+ ),
+ () => ({ text: `loading #${selected()}` }),
+ { on: () => selected() }
+ )
+ : () => ({ text: "select" })
+ );
+ createRenderEffect(
+ () => (view() as any)(),
+ v => void (screen = v)
+ );
+ });
+ const issues = [
+ { id: 1, title: "Login fails" },
+ { id: 3, title: "Crash on save" },
+ { id: 4, title: "Typo in footer" }
+ ];
+ const steps: [string, () => void][] = [
+ ["list lands", () => pick("list").res(issues)],
+ ["select #4", () => select(4)],
+ ["rename #4", () => rename(4, "Alpha")],
+ ["detail #4 lands", () => pick("detail:4").res({ id: 4, title: "Typo in footer" })],
+ ["select #3", () => select(3)],
+ ["close #3", () => close(3)],
+ ["close #4", () => close(4)],
+ ["rename #3", () => rename(3, "Delta")],
+ ["rename #4 lands", () => pick("rename:4").res({})],
+ ["detail #3 fails", () => pick("detail:3").rej(new Error("declined"))],
+ ["close #4 lands", () => pick("close:4").res({})],
+ ["rename #3 lands", () => pick("rename:3").res({})],
+ ["detail #3 lands", () => pick("detail:3").res({ id: 3, title: "Delta" })],
+ ["close #3 lands", () => pick("close:3").res({})]
+ ];
+ for (const [n, f] of steps) {
+ f();
+ await tick();
+ frames.push(`${n}: ${(screen as any)?.text}`);
+ }
+ dispose();
+ return frames;
+}
+
+test("#4841 a lane does not show a hold's staged error, nor the previous selection's detail after", async () => {
+ const frames = await run(true);
+ expect(frames.slice(9)).toEqual([
+ "detail #3 fails: loading #3",
+ "close #4 lands: loading #3",
+ "rename #3 lands: loading #3",
+ "detail #3 lands: loading #3",
+ "close #3 lands: #3 Delta (detail of #3)"
+ ]);
+ // Reading the guess changes nothing about what shows (F-3).
+ expect(frames).toEqual((await run(false)).map(f => f.replace("#4 Typo in footer", "#4 Alpha")));
+});
diff --git a/packages/web/test/failed-reask-stale-detail-4841.spec.tsx b/packages/web/test/failed-reask-stale-detail-4841.spec.tsx
new file mode 100644
index 0000000000..4fbf8b7499
--- /dev/null
+++ b/packages/web/test/failed-reask-stale-detail-4841.spec.tsx
@@ -0,0 +1,145 @@
+/**
+ * @jsxImportSource @solidjs/web
+ * @vitest-environment jsdom
+ */
+// #4841: a detail memo keyed on the selection fails while other actions are
+// out, and a rename's refresh asks it again. The heading reads the detail and
+// a `createOptimistic` rename guess, which made it a member of the guess's
+// lane: the lane published the failure the actions still held (``
+// flipped early), and when the re-ask's answer landed, still held, the
+// boundary recovered in the lane over the previous selection's committed
+// detail (`#3 Alpha (detail of #4)`). The hold's error is now the hold's: the
+// screen stays `loading #3` until the last action lands, as it does when the
+// heading reads `d.title` plainly. The signals version is
+// packages/signals/tests/lane-hold-staged-error-4841.test.ts.
+import { test, expect } from "vitest";
+import {
+ Loading,
+ Errored,
+ Show,
+ action,
+ createOptimistic,
+ createMemo,
+ createSignal,
+ refresh,
+ flush
+} from "solid-js";
+import { render } from "../src/index.js";
+
+const tick = async () => {
+ for (let i = 0; i < 4; i++) {
+ await new Promise(r => setTimeout(r, 0));
+ flush();
+ }
+};
+
+async function run(readGuess: boolean) {
+ const asks: { key: string; p: Promise; res: (v: any) => void; rej: (e: any) => void }[] = [];
+ // One flight per key while it is out, like the app's backend plumbing.
+ const ask = (key: string) => {
+ const o = asks.find(a => a.key === key);
+ if (o) return o.p;
+ let res: any, rej: any;
+ const p = new Promise((a, b) => ((res = a), (rej = b)));
+ asks.push({ key, p, res, rej });
+ return p;
+ };
+ const pick = (key: string) => {
+ const i = asks.findIndex(a => a.key === key);
+ if (i < 0) throw new Error("no ask " + key + " in " + asks.map(a => a.key));
+ return asks.splice(i, 1)[0];
+ };
+ const c = document.body.appendChild(document.createElement("div"));
+ const frames: string[] = [];
+
+ const [selected, setSelected] = createSignal(null);
+ const [renaming, guessRename] = createOptimistic<{ id: number; title: string }[]>(() => []);
+ const [, guessClose] = createOptimistic(() => []);
+
+ const list = createMemo(() => ask("list"));
+ const answer = createMemo(() => (selected() != null ? ask(`detail:${selected()}`) : undefined));
+ const detail = createMemo(() => (selected() == null ? null : answer()));
+ const heading = createMemo(() => {
+ const d: any = detail();
+ if (d == null) return "";
+ return readGuess
+ ? renaming().reduce((t, r) => (r.id === d.id ? r.title : t), d.title)
+ : d.title;
+ });
+
+ const select = action(function* (id: number) {
+ setSelected(id);
+ });
+ const rename = action(function* (id: number, title: string) {
+ guessRename(rs => [...rs, { id, title }]);
+ yield ask(`rename:${id}`);
+ refresh(list);
+ refresh(answer);
+ refresh(detail);
+ });
+ const close = action(function* (id: number) {
+ guessClose(cs => [...cs, id]);
+ yield ask(`close:${id}`);
+ refresh(list);
+ });
+
+ const dispose = render(
+ () => (
+
+ select
}>
+ loading #{selected()}}>
+ detail error: {e()?.message}
}>
+
+ #{selected()} {heading()} (detail of #{(detail() as any)?.id})
+
+
+
+
+
+ ),
+ c
+ );
+
+ const issues = [
+ { id: 1, title: "Login fails" },
+ { id: 3, title: "Crash on save" },
+ { id: 4, title: "Typo in footer" }
+ ];
+ const steps: [string, () => void][] = [
+ ["list lands", () => pick("list").res(issues)],
+ ["select #4", () => select(4)],
+ ["rename #4", () => rename(4, "Alpha")],
+ ["detail #4 lands", () => pick("detail:4").res({ id: 4, title: "Typo in footer" })],
+ ["select #3", () => select(3)],
+ ["close #3", () => close(3)],
+ ["close #4", () => close(4)],
+ ["rename #3", () => rename(3, "Delta")],
+ ["rename #4 lands", () => pick("rename:4").res({})],
+ ["detail #3 fails", () => pick("detail:3").rej(new Error("declined"))],
+ ["close #4 lands", () => pick("close:4").res({})],
+ ["rename #3 lands", () => pick("rename:3").res({})],
+ ["detail #3 lands", () => pick("detail:3").res({ id: 3, title: "Delta" })],
+ ["close #3 lands", () => pick("close:3").res({})]
+ ];
+ for (const [n, f] of steps) {
+ f();
+ await tick();
+ frames.push(`${n}: ${c.firstElementChild!.textContent}`);
+ }
+ dispose();
+ c.remove();
+ return frames;
+}
+
+test("#4841 after a failed detail is asked again, the screen never shows the previous selection's detail", async () => {
+ const frames = await run(true);
+ expect(frames.slice(9)).toEqual([
+ "detail #3 fails: loading #3",
+ "close #4 lands: loading #3",
+ "rename #3 lands: loading #3",
+ "detail #3 lands: loading #3",
+ "close #3 lands: #3 Delta (detail of #3)"
+ ]);
+ // Reading the guess changes nothing about when the detail shows (F-3).
+ expect(frames).toEqual((await run(false)).map(f => f.replace("#4 Typo in footer", "#4 Alpha")));
+});