Public: anyone can read this; the crew can change it.

A replace waits for the old machine to let go of the volume before making the new one #16346

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

Fixes #16342. Seen on the first real pinned forge (test1, DigitalOcean, production 0.7.645): a new claim link deleted the droplet and immediately asked for a new one with the same volume.

Notes

shipped production is serving it deploy 61d3d5c

opened this

Fixes #16342. Seen on the first real pinned forge (test1, DigitalOcean, production 0.7.645): a new claim link deleted the droplet and immediately asked for a new one with the same volume. DigitalOcean was still detaching the volume from the deleted droplet and answered 422; the row was left failed with no machine until the same call was made again a minute later. Update and rollback take the same path, so any replace could leave a sold forge dark.

What changed

  • Each driver says whether its volume is attached to nothing (volumeFree: DigitalOcean GET /v2/volumes/{id} droplet_ids, Hetzner GET /v1/volumes/{id} server).
  • replace (src/cloud/machine.ts) waits for that after deleting the old machine, asking every 5 s for up to 3 min, then refuses with "the old machine still holds the data volume; nothing new was made: ask again in a minute".

Tested on Bun 1.4.2: typecheck clean, every pinned test file passes including those needing a socket (call sequences now include the volume read), plus a new test/pinned-detach.test.ts: a volume held for two asks then freed makes exactly one machine; one never freed makes none and says so.

🤖 Generated with Claude Code

Approved

The replace now waits until the cloud says the volume is attached to nothing, then makes the machine. That fixes the 422 that left test1 with no machine (#16342). The change is small, one concept, and adds no dependency. Both drivers implement volumeFree, and capped spreads the driver so the new method survives. Two new tests cover the wait and the timeout, and the existing call-order tests are updated. The change adds no page, so I did not walk the preview.

Two things I would do next:

  1. The wait can run for 180 s inside the request that asked for the replace. Make sure the person sees progress or a clear 'waiting for the old machine' state, not a hung button. Better still, move the wait to a background retry.
  2. If the wait times out, the old machine is already deleted and the recorded remote is cleared. The error says 'ask again in a minute', so check that asking again goes straight to the wait, then the create, and does not delete twice.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs