[Bugfix #1110] Fix flaky artifact-canvas D2 watch-failure test (missing waitFor)#1111
Conversation
The test 'surfaces a synchronous FileAdapter.watch() failure via onError
without throwing (D2)' asserted document.querySelector('p[data-line]')
synchronously right after awaiting onError. The async read() render can
resolve after onError fires; under CI load the DOM read landed before the
paragraph was in the tree, flaking the test.
Wrap the assertion in waitFor to match the sibling idempotent-dispose test's
pattern. Semantics unchanged; only timing tolerance widens.
Fixes #1110
…itFor CMAP (claude) flagged the identical bare-assertion-after-waitFor race in the sibling test 'surfaces adapter errors via onError and does not throw; failed list keeps prior markers (D2)'. Same root cause: onError can fire before the async read() render flushes. The issue invited fixing such patterns as a ride-along since the file is small. One-line, semantics unchanged.
CMAP review (3-way)
All three approved the one-line fix. Claude's review flagged the identical bare-assertion-after- |
Architect ReviewLow-risk BUGFIX. Two-line diff in
Three-way CMAP unanimous APPROVE (gemini + codex + claude). 56/56 tests pass. No production code changes; semantics preserved (the assertion still eventually succeeds, just with retry tolerance matching the sibling test's pattern). APPROVE. Ready for the pr gate. Architect review |
Summary
Fixes a CI-load flake in the artifact-canvas test
surfaces a synchronous FileAdapter.watch() failure via onError without throwing (D2).Root Cause
The test awaited
onErrorfiring, then asserted the DOM synchronously on the next line:ArtifactCanvas's asyncread()render can resolve afteronErrorfires. Under CI load the render is delayed enough that the synchronous DOM query runs before the paragraph is in the tree, so the assertion intermittently fails. The sibling test directly below (Disposable.dispose is safe to call more than once) already uses the correctwaitFor-wrapped pattern.Fix
Wrap the second assertion in
waitForto match the sibling test's pattern:Semantics are unchanged (the assertion still must eventually hold); only the timing tolerance widens. One-line change, no production code touched.
Test Plan
pnpm --filter @cluesmith/codev-artifact-canvas test→ 56/56 pass.pnpm build+pnpm testgreen (verified via porch checks: build ✓, tests ✓).Regression Coverage
This is a test-timing fix to a race, so the corrected D2 test is the regression coverage: with the bare synchronous read it flakes under load; with the
waitForwrapper it is deterministic. An additional standalone test would only re-assert the same behavior.Fixes #1110