Skip to content

Commit 702c541

Browse files
cliffhallclaude
andcommitted
test(web): preserve the drain error as cause + route the guard message to the reachable cause (round 11)
Round-11 review of PR #1793 (merge-verdict; two optional polish items): - Finding 1: when both a liveness error and a drain-time throw occur, the drain error was dropped entirely. It's now attached as the liveness error's `cause` (when the liveness error is an Error), so an act-surfaced component error from the settling render is preserved without changing which error fails the test. - Finding 2: the guard's error message pointed the reader first at the `sequence.hooks: "stack"` pin, which the file itself documents as defense-in-depth and NOT the ordering guarantee. Reworded to name the actually- reachable cause first — cleanup moved to a same-level afterEach instead of the setup.ts setupFile (outer) hook — and demote the pin to a parenthetical, so a maintainer who trips the check isn't sent to investigate a non-causal setting. Verified: a bare mid-body cleanup() throws the reworded message; eslint clean; ViewHeader unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
1 parent c0a1383 commit 702c541

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

‎clients/web/src/test/renderWithMantine.tsx‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,15 @@ afterEach(async () => {
219219
if (livenessError === undefined) captureLiveness("after");
220220
// A liveness error explains the actual regression; a drain-time throw
221221
// (realistically only `act` surfacing an error flushed during the settle) is a
222-
// downstream symptom — so prefer the liveness error, else rethrow the drain's.
223-
if (livenessError !== undefined) throw livenessError;
222+
// downstream symptom — so prefer the liveness error. Preserve the drain error
223+
// as its `cause` rather than dropping it, so a component error flushed during
224+
// the settle isn't lost when both fire. Otherwise rethrow the drain's.
225+
if (livenessError !== undefined) {
226+
if (drainError !== undefined && livenessError instanceof Error) {
227+
livenessError.cause = drainError;
228+
}
229+
throw livenessError;
230+
}
224231
if (drainError !== undefined) throw drainError;
225232
});
226233

@@ -236,15 +243,16 @@ function assertLiveContainersConnected(
236243
if (containers.some((c) => !c.isConnected)) {
237244
throw new Error(
238245
`renderWithMantineTransitions auto-settle: a still-mounted tree was ` +
239-
`detached ${when} the settle. Expected cause: setup.ts's cleanup() ran ` +
246+
`detached ${when} the settle — setup.ts's cleanup() ran ` +
240247
(when === "before" ? "entirely first" : "concurrently mid-settle") +
241-
" — the afterEach ordering this depends on broke, so the settle drained " +
242-
"nothing and the #1760 leak is reopened (this hook must run and complete " +
243-
"before cleanup; see the ordering note here and the `sequence.hooks: " +
244-
'"stack"` pin in vite.config.ts). If instead the test unmounted the tree ' +
245-
"itself, use the `unmount()` returned by renderWithMantineTransitions " +
246-
"(which drops the tree from the liveness set) rather than a bare RTL " +
247-
"unmount.",
248+
", so the settle drained nothing and the #1760 leak is reopened. This " +
249+
"hook must run and complete before cleanup, which holds because " +
250+
"cleanup() is a setupFile (outer) hook; the likely cause is cleanup " +
251+
"having been moved to a same-level afterEach (the `sequence.hooks` pin " +
252+
"is defense-in-depth, not the guarantee — see the ordering note here). " +
253+
"If instead the test unmounted the tree itself, use the `unmount()` " +
254+
"returned by renderWithMantineTransitions (which drops the tree from the " +
255+
"liveness set) rather than a bare mid-body `cleanup()`.",
248256
);
249257
}
250258
}

0 commit comments

Comments
 (0)