Skip to content

fix(runner): the leak spec must poll KV list(), not read it once (DEV-2567) - #255

Open
danielzytohoc wants to merge 2 commits into
masterfrom
fix/DEV-2567-leak-spec-kv-consistency
Open

fix(runner): the leak spec must poll KV list(), not read it once (DEV-2567)#255
danielzytohoc wants to merge 2 commits into
masterfrom
fix/DEV-2567-leak-spec-kv-consistency

Conversation

@danielzytohoc

@danielzytohoc danielzytohoc commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

First production execution of this spec — unlocked by the new E2E_API_TOKEN (DEV-2583) — failed its positive control in run 32491144642: a create nobody abandoned is still metered read the admin panel once, immediately after the create's 200. Test bug, not product: the meter put is awaited before the response, but the panel enumerates session-meter: keys with KV list(), which is eventually consistent on real Cloudflare KV — a fresh key can lag its own put by seconds (documented worst case 60s). wrangler dev's KV is immediate, so the single-shot read had only ever been exercised where it couldn't lose.

The diagnosis exposed a second, subtler hole: inside that same lag window the two .not.toContain() tests were vacuous — a leaked phantom meter (written before the 410 returns) wouldn't be visible in list() yet either, so they passed leak or no leak. Fixes:

  • the positive containment and the post-teardown clearance now poll via toPass (90s ceiling, 2s intervals), with the mechanism explained inline;
  • the two absence tests sample a sustained 45s window (expectNeverMetered) instead of reading once — absence under eventual consistency can't be proven with one read, and the positive control demonstrates a real key surfaces well within the same window.

Verified against prod from this branch (run 32492510913, full workflow green): all 3 leak tests + the authed share round-trip pass — 4/4 in 3.1m. The positive control took 50.6s where it used to fail instantly, i.e. the poll absorbed real, observed list() lag.


Note

Low Risk
Test-only change to polling/timeouts; no product, auth, or metering logic is modified.

Overview
Stops the abandoned-create leak spec from treating a single /admin panel read as proof. Production KV list() is eventually consistent (up to ~60s), so a one-shot .toContain() failed the positive control and a one-shot .not.toContain() could pass even if a phantom meter existed.

Absence checks now sample for 90s via expectNeverMetered (5s interval). The live-session and teardown assertions poll with toPass (90s, 2s). Tests get a 240s timeout so the window exceeds documented KV lag with margin.

Reviewed by Cursor Bugbot for commit 7acdc44. Bugbot is set up for automated code reviews on this repo. Configure here.

…-2567)

First production execution of this spec (the E2E_API_TOKEN secret now
exists) failed its positive control: the meter put is awaited before
the create's 200, but the admin panel enumerates meters with KV
list(), which is eventually consistent on real Cloudflare KV — a fresh
key lags its own put by seconds (documented worst case 60s). wrangler
dev's KV is immediate, so the single-shot reads only ever passed
locally. The containment checks now poll, and the two absence tests
sample a sustained 45s window instead of one read — a leaked phantom
is written before the 410 returns, so inside the lag window a
single-shot .not.toContain() passed leak or no leak.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 593ae22. Configure here.

Comment thread runner/e2e/session-abandoned-create.spec.ts
@danielzytohoc
danielzytohoc requested a review from demtario August 21, 2026 15:14
…ugbot, #255)

45s undercut the 60s list() worst case the comment itself cites, so a
phantom surfacing in the 45-60s gap escaped both absence tests — the
same vacuity this PR closes, one constant deeper. The window now
mirrors the 90s ceiling the positive polls get: whatever propagation a
real key is allowed, a phantom must be waited out for.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant