Skip to content

fix: stop waiting for the snapshot store once the run stops - #496

Merged
Sequela02 merged 1 commit into
devfrom
fix/stop-base-capture
Oct 18, 2026
Merged

Sequela02 merged 1 commit into
devfrom
fix/stop-base-capture

Conversation

@Sequela02

Copy link
Copy Markdown
Contributor

Part 7 of the move to Effect became fixing the places in the engine's loop that do not hear a stop (debated with GPT-6 Astra and GPT-6.1 Sol, and measured; the owner approved fixing them directly rather than moving loop.ts to Effect). This is the request's base. Found by Sol reading the code; reproduced and fixed by Claude.

Defect

Before a request runs, the loop records its base (captureBase), and in a folder outside Git that takes a snapshot under the snapshot store's lock, waiting up to 30 s for another session's snapshot. None of it heard the stop, and abort() awaits the run, so stopping a request while the store was held waited out the 30 s. Reproduced on dev with the real path: the test holds the store's lock, starts a request in a folder outside Git and stops it; abort() returned after 30.2 s.

Change

  • withLockWhile takes an optional signal: a stop ends the wait for the lock (refused as the lock being held). Work that already holds the lock runs to its end, so the lock is never released under it.
  • takeSnapshot takes the signal: it does not wait for the store, nor start a Git step, once the run is stopped, and returns "the run was stopped before the snapshot was taken". A Git step under way is short and runs to its end: gitOutput already explains why Git is not killed (on Windows git can be a launcher, and killing it leaves Git running).
  • captureBase and the loop pass the run's signal through; HostParts.withLockWhile and LoopOptions.captureBase take it.

Checks

  • New test in packages/core/tests/snapshot.test.ts: the store held by another, a request started and stopped; it ends aborted within 5 s, with the base's unit refused for the stop. On dev it waits 30 s and fails; with the change it passes.
  • bun run check locally (Windows): Tests 264 passed (264); 332 pass; 3 skip; Over budget: shellRssBytes: 120913920 is over its limit of 115000000.

A request outside Git records its base by snapshotting under the store's lock, waiting up to 30 s for another session's snapshot, and nothing of it heard the stop, so abort() waited out the 30 s. The run's signal now reaches captureBase, takeSnapshot and withLockWhile: a stop ends the wait for the lock and starts no Git step, while work that holds the lock runs to its end. Found by Sol reading the loop; reproduced with the store held by another.
@Sequela02
Sequela02 force-pushed the fix/stop-base-capture branch from d01b8b9 to ea63a31 Compare October 18, 2026 19:27
@Sequela02
Sequela02 merged commit aa05cfd into dev Oct 18, 2026
9 checks passed
@Sequela02
Sequela02 deleted the fix/stop-base-capture branch October 18, 2026 19:40
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