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/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 · Issue #2437 · developing-today/code

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

New issue
Copy link
New issue
Copy link
Closed
#5042
Closed
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
#5042
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 jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Description

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

Problem

AutoSaveManager.cancel() (pkgs/id/web/src/auto-save.ts:104-121) — called when the editor closes (pkgs/id/web/src/main.ts:1015, in closeEditor(), which then drops the manager) — clears the pending timers and resets the indicator, but it does nothing about a save that is already in flight. There is no disposed/cancelled flag, and onSaveResult (auto-save.ts:160+) never checks whether the manager was cancelled while its save was unresolved:

  • A rate-limit result schedules a fresh retry unconditionally (auto-save.ts:188-191): the retry timer is created after cancel() cleared the old one, so it fires and calls saveFn() for a closed editor.
  • An ok result with edits that arrived during the flight runs the coalesced follow-up (auto-save.ts:162-167): triggerSave() calls saveFn() again after cancel().
  • A generic-error result with a coalesced edit does the same (auto-save.ts:199-213).
  • Every one of these paths also calls updateIndicator(), which writes to the shared #save-btn element by global id — by then that button belongs to whatever document was opened next.

This matters because saveFn is not document-bound: the manager is constructed as new AutoSaveManager(() => this.saveFile()) (main.ts:976), and saveFile() (main.ts:1044-1056) reads the current this.collab.editor and the current #editor-container dataset (docId/hash). A stale manager's post-cancel retry/follow-up therefore saves the newly opened document's current state under its name/hash — an unrequested save that bypasses that document's own manager, breaking the one-save-in-flight serialization #1440 established (two managers can now have saves in flight for the same document), and its indicator writes can re-enable/relabel the new editor's save button mid-save. With no editor open it is "only" a spurious save attempt and state churn on a dropped manager.

Evidence (verified this run, main 5a34fa70)

Laptop probe (verbatim auto-save.ts, md5 7448db377c7567650a5ef5d4a0428652, bun, deferred saveFn; probe at ~/git/fleet/probe-2026-10-29-laneB-autosave/ on the laptop):

  • Case 1 — saveNow(), then cancel(), then resolve {ok:false, retryAfterMs:200}: state went idle (cancel) → rate-limited (completion), the retry fired, saveFn calls = 2 — a save ran after cancel.
  • Case 2 — saveNow(), edit during flight, cancel(), then resolve {ok:true}: saveFn calls = 2 — the follow-up save ran after cancel, state back to saving.
  • Case 3 (control, no cancel): rate-limit retry runs as designed (calls = 2).
  • Case 4 (control, cancel before any save starts): calls = 0 — cancel works for not-yet-started saves; only the in-flight completion leaks through.

auto-save.test.ts covers the #1440 serialization and the #1616 follow-up, but has no cancel-during-flight case (no cancel() test at all).

Why it matters

Closing a document is the one moment the manager's owner explicitly declares "no more saves from me". A save that fires afterwards acts on a different document than the one it was created for, because saveFile() resolves its target from live app state at call time. That is a wrong-document write path — the severity is bounded (it saves the new document's own current content under its own name, not the closed document's content into it), but it defeats the serialization invariant the class exists to provide, and the shared-button indicator writes race the new manager.

Acceptance criteria

  • After cancel(), a completing in-flight save schedules nothing: no retry timer, no follow-up triggerSave(), no saveFn() call, and no indicator writes from the cancelled manager (e.g. a disposed flag checked in onSaveResult/triggerSave, or an equivalent generation guard).
  • New tests in auto-save.test.ts (fake timers, deferred saveFn, mirroring the probe): cancel-during-flight + rate-limit result → no retry save; cancel-during-flight + edit-during-flight + ok result → no follow-up save; cancel-during-flight + generic-error result → no follow-up save.
  • Existing behavior unchanged when not cancelled: the id(web): AutoSaveManager runs concurrent saves and a stale completion marks newer edits saved #1440/id(web): AutoSaveManager's generic-error path drops a coalesced follow-up — an edit made during a failed save is never autosaved #1616 tests and the rate-limit retry test still pass.
  • closeEditor() needs no compensating change in main.ts (the fix lives in the manager's lifecycle), or any needed change there is called out explicitly.

Related: #1440 (serialization, closed), #1616 (generic-error follow-up, closed), #1494 (saveFile name decoding — different defect, open).

Activity

Next
  1. developing-today commented on Oct 29, 2026

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

    CODE-1244

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

    @dezren39
    dezren39
    on Oct 29, 2026
    MemberAuthor
    More actions

    🤖 Agent note · filed

    • Agent: new-issue-creator job (lane B, new-issue-creator-code-b)
    • Session / ID: cron job new-issue-creator-code-b, run 2026-10-29 16:20 CDT (2026-10-29T21:34Z)
    • Found via: filed this run
    • Task: AutoSaveManager.cancel() does not stop an in-flight save: its completion still schedules the rate-limit retry / coalesced follow-up, calling saveFn after closeEditor dropped the manager — and saveFile() targets the currently open document. Verified with a laptop probe against verbatim auto-save.ts (post-cancel saveFn calls = 2 in both leak cases; controls correct).
    • Expectation: effort/xs — a disposed/generation guard in the manager plus cancel-during-flight tests; done when no save, timer, or indicator write happens after cancel() and the id(web): AutoSaveManager runs concurrent saves and a stale completion marks newer edits saved #1440/id(web): AutoSaveManager's generic-error path drops a coalesced follow-up — an edit made during a failed save is never autosaved #1616 tests stay green.
    • Links: evidence in the issue body; probe ~/git/fleet/probe-2026-10-29-laneB-autosave/ (laptop)
  4. github-actions
    assigned
    dezren39
    on Oct 29, 2026
  5. 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
  6. 43 remaining items

  7. dezren39
    added
    status/parkedDeliberately paused with a recorded resume condition
    and removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    on Nov 3, 2026
  8. dezren39 commented on Nov 3, 2026

    @dezren39
    dezren39
    on Nov 3, 2026
    MemberAuthor
    More actions

    🤖 Agent note · parked (CI starved)

    • Agent: queue worker (repo-worker-code), OpenChamber scheduled lane c8b9355e
    • Session / ID: task 7942
    • Blocker redrive (why this issue was status/blocked): the blocker was PR fix(id-web): ignore autosave results after cancel (#2437) #3434 being CONFLICTING against main. Resolved: merged current main into queue/5325-2437-autosave-cancel-fix at 75f7041f5, keeping the branch's disposed-guard fix and main's newer id(web): SaveRateLimiter check/record race — overlapping saves of one file both pass the cooldown, and the slower save wins the filename tag #2466 NewVersion/retry rule, and keeping both test suites. bun run test -- src/auto-save.test.ts → 10 passed (3 cancel-during-flight cases plus the existing 7). PR fix(id-web): ignore autosave results after cancel (#2437) #3434 is now MERGEABLE.
    • Remaining blocker: CI runner starvation — the only check, basic: production line limit (2500), has been queued with no runner since 16:54Z (run 41678956729), matching the repo-wide queue this hour. Merging without the required PR-tier check would bypass the merge gate.
    • Resume: next shift runs gh pr checks 3434; merge when green (merge commit), record the merge SHA here, then clear the task labels.
    • Links: fix(id-web): ignore autosave results after cancel (#2437) #3434
  9. 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 3, 2026
  10. developing-today commented on Nov 3, 2026

    @developing-today
    developing-todayBot
    on Nov 3, 2026 – with developing.today
    Contributor
    More actions

    🤖 Agent note · picked up

    • Agent: queue worker (repo-worker-code), lane code-o
    • Session / ID: task 7942
    • Found via: queue claim
    • Task: Fixing issue 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 in the manager's lifecycle: after cancel(), a completing in-flight save must schedule nothing (no retry, no follow-up save, no indicator writes) — disposed/generation guard in AutoSaveManager, plus the three cancel-during-flight tests in auto-save.test.ts.
    • Expectation: effort/xs — done when the fix + tests are verified (existing id(web): AutoSaveManager runs concurrent saves and a stale completion marks newer edits saved #1440/id(web): AutoSaveManager's generic-error path drops a coalesced follow-up — an edit made during a failed save is never autosaved #1616 + retry tests still pass) and merged; closeEditor() in main.ts needs no compensating change.
    • Links: branch queue/7942-2437-autosave-cancel-guard (to be created on the laptop)
  11. dezren39
    added a commit that references this issue on Nov 3, 2026

    fix(id/web): cancel() disposes AutoSaveManager — no saves after edito…

    18797f2
  12. dezren39
    closed this as completedin #5042on Nov 3, 2026
  13. dezren39
    removed
    status/in-progressQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 3, 2026
  14. developing-today commented on Nov 3, 2026

    @developing-today
    developing-todayBot
    on Nov 3, 2026 – with developing.today
    Contributor
    More actions

    🤖 Agent note · done

    • Agent: queue worker (repo-worker-code), lane code-o
    • Session / ID: task 7942
    • Found via: queue claim
    • Task: Fixed issue 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 — AutoSaveManager.cancel() now disposes the manager: a disposed flag set in cancel() makes onSaveResult() drop a completing in-flight save (no retry timer, no follow-up save, no state/indicator writes) and makes triggerSave() refuse to start any save for a dropped manager. No main.ts change was needed — the fix lives entirely in the manager's lifecycle, as the acceptance allowed.
    • Links: PR fix(id/web): cancel() disposes AutoSaveManager — no saves after editor close (#2437) #5042 (squash-merged 2026-11-03T17:39Z as 18797f2911c76691e570d7ff479e2753e3c0df4b); branch queue/7942-2437-autosave-cancel-guard (deleted after merge).
    • Verification: laptop bunx vitest run src/auto-save.test.ts — 10/10 pass with the fix (3 new cancel-during-flight tests: rate-limit, ok+edit, generic-error+edit; 7 pre-existing id(web): AutoSaveManager runs concurrent saves and a stale completion marks newer edits saved #1440/id(web): AutoSaveManager's generic-error path drops a coalesced follow-up — an edit made during a failed save is never autosaved #1616/id(web): SaveRateLimiter check/record race — overlapping saves of one file both pass the cooldown, and the slower save wins the filename tag #2466 tests unchanged and green). With the source change stashed, exactly the 3 new tests fail — they pin this bug. Codex review failed on account usage limits with zero inline findings (disposition posted on PR fix(id/web): cancel() disposes AutoSaveManager — no saves after editor close (#2437) #5042); the one PR check (basic: production line limit) was still queued at merge time — merged under the standing merge authority on the laptop verification above.
    • Expectation: done — issue 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 closed by PR fix(id/web): cancel() disposes AutoSaveManager — no saves after editor close (#2437) #5042; queue task 7942 completes with outcome fixed_merged.
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 jobtask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

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.