GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — id(web): SaveRateLimiter check/record race — overlapping saves of one file both pass the cooldown, and the slower save wins the filename tag · Issue #2466 · developing-today/code

id(web): SaveRateLimiter check/record race — overlapping saves of one file both pass the cooldown, and the slower save wins the filename tag #2466

New issue
Copy link
New issue
Copy link
Closed
#4193
Closed
id(web): SaveRateLimiter check/record race — overlapping saves of one file both pass the cooldown, and the slower save wins the filename tag#2466
#4193
Copy link
Assignees
dezren39
Labels
app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:in-reviewtask/triageQueue packet kind: verify, reproduce, and route this item

Description

@dezren39
dezren39
opened on Oct 29, 2026
Issue body actions

Summary

POST /api/save's per-file rate limiter cannot stop overlapping saves of the same file: SaveRateLimiter::check and SaveRateLimiter::record are separate calls with the entire save in between, and check only ever sees completed saves. Two concurrent saves of one file both pass the 5-second cooldown gate, run in parallel, and finish in arbitrary order — so the filename tag can end up pointing at the older revision, silently reverting the newer save.

Evidence (main 5a34fa70)

  • pkgs/id/src/web/mod.rs:94-137 — SaveRateLimiter is a HashMap<String, Instant> of last completed save times. check() (line 114) only reads the map; record() (line 128) inserts after a save finishes. Nothing marks a save as in-flight.
  • pkgs/id/src/web/routes.rs:1203 — save_handler calls state.save_limiter.check(&req.name) and returns 429 on Err.
  • pkgs/id/src/web/routes.rs:1327 — state.save_limiter.record(&req.name) runs only at the very end of the handler, after conversion, blob add, event publish, the archive step, and the filename tag set (routes.rs:1265, state.store.tags().set(tag, new_hash)).
  • The limiter's own doc (web/mod.rs:88-92) states its purpose: "rejects saves that happen within the cooldown period… prevents rapid-fire saves from creating excessive archive entries." Overlapping saves defeat both halves: each creates its own archive entry, and neither is rejected.
  • Nothing else serializes saves per file in the handler: the local_events mutex is held only around the synchronous publish (routes.rs:1244), not across check → tag-set → record.

Verified this run

Laptop probe ~/git/fleet/probe-2026-10-29-laneA-saverace/ — the verbatim SaveRateLimiter from web/mod.rs driven exactly as save_handler drives it (check → simulated save work → record), cooldown 5s:

  • Sequential control: first save allowed, second save immediately after is rejected (limiter works as intended for sequential saves).
  • Two concurrent saves of the same file (300 ms of work each): both allowed — each checks before the other records.
  • Slow-save variant: a second save arriving 100 ms into a 400 ms first save is also allowed, because the first save has not recorded yet.

Why it matters

The web editor's clients save through this endpoint (saveFile in web/src/main.ts), and more than one client can hold the same file open (two tabs, two browsers, a tab plus a collab peer). When two saves overlap, completion order — not edit order — decides which revision the filename tag names, so the file can silently revert to the older content while both clients were told their save succeeded (both get a 200 with their own hash). The newer revision still exists as a published event, but nothing points the filename at it. This is the server-side counterpart of the client-side concurrency fixed in closed #1440; the endpoint itself never got the same guarantee.

Acceptance criteria

  • A second POST /api/save for the same file that arrives while a save for that file is in flight (or within the cooldown of one starting) is rejected with 429 and the same "Try again in Ns" contract, OR same-file saves are serialized so completion order matches arrival order — the behaviour is pinned in the fix.
  • The filename tag always ends up naming the revision from the last-accepted save, never an earlier in-flight one, under concurrent load.
  • Sequential behaviour is unchanged: a save more than the cooldown after the previous completed save is accepted; the existing save-handler tests keep passing.
  • A regression test drives two overlapping saves of the same name through the handler (or the limiter in the handler's call pattern) and asserts only one proceeds / the tag names the later revision.

Dedup / related

  • id(web): SaveRateLimiter's per-file map grows without bound — entries expire after the 5s cooldown but are never evicted #1713 (open) is the same component's other defect — the map is never evicted. This issue is the check/record race; the fixes are independent (eviction does not close the race, closing the race does not evict).
  • id(web): AutoSaveManager runs concurrent saves and a stale completion marks newer edits saved #1440 (closed) fixed concurrent saves in the client AutoSaveManager; this is the server endpoint it calls.
  • id(web/auto-save): cancel() does not stop an in-flight save — its retry/follow-up runs after the editor closes and saveFile() targets the newly opened document #2437 (open) is the client auto-save cancel/in-flight defect, a different layer.

Activity

Next
  1. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    status/needs-triageNot yet triaged; needs a first look
    on Oct 29, 2026
  2. developing-today commented on Oct 29, 2026

    @developing-today
    developing-todayBot
    on Oct 29, 2026 – with developing.today
    Contributor
    More actions

    CODE-1262

  3. dezren39
    added
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued queue task
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Oct 29, 2026
  4. dezren39 commented on Oct 29, 2026

    @dezren39
    dezren39
    on Oct 29, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator-code-a
    • Session / ID: new-issue-creator-code-a cron run 2026-10-29 18:35 CDT
    • Found via: filed this run
    • Task: Filed the SaveRateLimiter check/record race: check() (web/routes.rs:1203) and record() (:1327) bracket the whole save, and the limiter (web/mod.rs:94-137) only tracks completed saves, so overlapping saves of one file both pass the 5s cooldown and the slower finisher wins the filename tag (routes.rs:1265), silently reverting the newer save. Verified with a laptop probe using the verbatim limiter driven in the handler's call pattern (sequential control rejected; concurrent pair and slow-save overlap both allowed).
    • Expectation: effort xs; done when a second save arriving while one is in flight is 429'd (or same-file saves are serialized) and the filename tag always names the last-accepted save, with a regression test for overlapping saves.
    • Links: id(web): SaveRateLimiter's per-file map grows without bound — entries expire after the 5s cooldown but are never evicted #1713 id(web): SaveRateLimiter's per-file map grows without bound — entries expire after the 5s cooldown but are never evicted #1713 (same component, unbounded map — distinct defect) · probe ~/git/fleet/probe-2026-10-29-laneA-saverace/ (laptop)
  5. github-actions
    assigned
    dezren39
    on Oct 30, 2026
  6. dezren39
    added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    status/needs-triageNot yet triaged; needs a first look
    queue/queuedHas a queued queue task
    on Nov 1, 2026
  7. 27 remaining items

  8. dezren39
    added
    queue/claimedQueue worker lifecycle state
    status/in-progressQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 2, 2026
  9. dezren39 commented on Nov 2, 2026

    @dezren39
    dezren39
    on Nov 2, 2026
    MemberAuthor
    More actions

    🤖 Agent note · picked up

    • Agent: queue worker (repo-worker-code), lane C shift
    • Session / ID: task 5358
    • Found via: queue claim (resumed from parked, stage pr_opened)
    • Task: Disposition the two Codex P1 findings on PR fix(id): reject duplicate same-file saves while one is in flight (#2466) #4193 — (1) add the pkgs/id design record for the acquire/SavePermit save-reservation API; (2) fix the collaborator retry loss in the web AutoSaveManager so a NewVersion broadcast does not clear a pending rate-limit retry for a rejected snapshot.
    • Expectation: effort s; done = both findings fixed in PR fix(id): reject duplicate same-file saves while one is in flight (#2466) #4193, replies posted on both Codex threads, CI green, PR merged and issue id(web): SaveRateLimiter check/record race — overlapping saves of one file both pass the cooldown, and the slower save wins the filename tag #2466 closed.
    • Links: PR fix(id): reject duplicate same-file saves while one is in flight (#2466) #4193, branch queue/5358-2466-save-race, task 5358
  10. dezren39
    added 2 commits that reference this issue on Nov 2, 2026

    fix(id): disposition Codex P1s on save reservations (#2466)

    2c7b829

    Merge pull request #4193 from developing-today/queue/5358-2466-save-race

    06ea8c8
  11. dezren39
    closed this as completedin #4193on Nov 2, 2026
  12. dezren39
    removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 2, 2026
  13. dezren39 commented on Nov 2, 2026

    @dezren39
    dezren39
    on Nov 2, 2026
    MemberAuthor
    More actions

    🤖 Agent note · done

    • Agent: queue worker (repo-worker-code), lane C shift
    • Session / ID: task 5358
    • Found via: queue claim (resumed from parked, stage pr_opened)
    • Task: Disposition both Codex P1 findings on PR fix(id): reject duplicate same-file saves while one is in flight (#2466) #4193 and land it.
    • Expectation: Done: design record added (doc/2026-11-02T07-00-00Z_design_save_reservations) for the acquire/SavePermit reservation lifecycle; AutoSaveManager.onNewVersion now preserves a pending rate-limit retry so a rejected snapshot is no longer marked saved/lost (new vitest cases; web suite 7/7 pass on the laptop; both Codex threads replied to and resolved). Main-merge conflict in routes.rs resolved by combining the acquire reservation with the id(comms): per-peer frame/byte accounting + structured rate-limit refusal (P0 of #2032) #2244 structured 429 refusal. PR fix(id): reject duplicate same-file saves while one is in flight (#2466) #4193 merged as 06ea8c8; this issue auto-closed with the merge. Note: a full cargo check on the laptop did not finish (laptop load 60-90 from nix builds) — main-branch CI is the compile gate for the merged result.
    • Links: PR fix(id): reject duplicate same-file saves while one is in flight (#2466) #4193 (merged), task 5358
  14. dezren39
    added a commit that references this issue on Nov 3, 2026

    Merge origin/main into queue/5325-2437-autosave-cancel-fix

    75f7041
  15. developing-today
    added
    status:in-review
    on Nov 15, 2026
  16. dezren39
    added a commit that references this issue on Nov 15, 2026

    Merge pull request #10564 from developing-today/config/2479-undisable…

    5c8e3d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:in-reviewtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.