Skip to content

The partial-reset test reads the storage keys after the autosave has landed - #651

Merged
MerciHanrim merged 1 commit into
mainfrom
e423-wait-for-autosave
Nov 23, 2026
Merged

MerciHanrim merged 1 commit into
mainfrom
e423-wait-for-autosave

Conversation

@MerciHanrim

Copy link
Copy Markdown
Owner

Part of #623 (its first item). Test only; no product change.

What was wrong

e2e/error-paths-423.spec.ts, "Reset all data: a removal refused after others succeeded …", failed now and then with expect(after).toBeLessThan(before) — Expected: < 4, Received: 4, on the first try and on its retry (#609's CI, shard 1/8; #576's CI, shard 5/8). A job rerun of the same head passed.

The cause is in the test. resetAll() (e2e/support/loop.ts) calls newGraph(), which schedules the autosave 400 ms later (src/store/graphStore.ts:961). The test read the keys and then ran a partial reset; when that write of loop-studio:graph:v1 landed between the two, one key went (storage-mode) and one arrived (graph:v1), so the count did not move. The partial reset leaves storage open, so the late write is not stopped. A retry runs the same steps in a fresh context on the same slow runner and meets the same window.

At normal speed the write came after the test, so graph:v1 did not exist when the reset ran: the refused second removal was a removal of nothing.

The change

Only e2e/error-paths-423.spec.ts:

  • after resetAll, the pending autosave is written (__loop.autosave.flush(), the pagehide path, used by ten other specs) and the test waits until loop-studio:graph:v1 is stored, before it patches removeItem and reads the keys;
  • instead of the total count, it checks that exactly loop-studio:storage-mode was removed, that no key arrived, and that loop-studio:graph:v1, whose removal was refused, is still there.

Evidence

The slow condition: the CPU throttled ×3 (CDP Emulation.setCPUThrottlingRate), the old and the new test body copied as they are, 10 runs each, one worker, no retries:

×3, 10 runs
old (main 14514210) 5 failed, each with Expected: < 4, Received: 4, as on CI
new (this branch) 10 passed

Earlier probes of the same steps: the old test failed 4 of 5 (2026-11-22) and 2 of 5 (2026-11-23) at ×3, and passed at ×1 and ×6; with the flush first it passed 15 of 15 at ×1, ×3 and ×6, the removed key always storage-mode and nothing arriving.

The fixed test at normal speed, --repeat-each=20, one worker, no retries: 20 passed. The whole spec file: 3 passed.

Local:

  • every check:* script: 0 failed;
  • tsc -b: clean;
  • lint: 88 warnings, the baseline.

No unit test or other spec changes. CI cannot be throttled, so the repeated runs above are the evidence that the window is closed.

…landed

Part of #623. resetAll() schedules the autosave 400 ms later; on a slow runner its write landed between the key read and the partial reset, and the count check failed on both attempts. The test now flushes the pending autosave and waits for the document record first, and checks that exactly the storage mode was removed, nothing arrived and the refused document record stays. Test only.
@MerciHanrim MerciHanrim added the bug Something isn't working label Nov 23, 2026
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying cozy-loop-studio with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4a3648c
Status: ✅  Deploy successful!
Preview URL: https://f08ef3cc.cozy-loop-studio.pages.dev
Branch Preview URL: https://e423-wait-for-autosave.cozy-loop-studio.pages.dev

View logs

@MerciHanrim
MerciHanrim merged commit c309293 into main Nov 23, 2026
13 checks passed
@MerciHanrim
MerciHanrim deleted the e423-wait-for-autosave branch November 23, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant