fix(pull-zone): Roll back bunny zone on creation/hostname failure#33
Merged
Conversation
Wraps createPullZone and addCustomHostname multi-step flows in best-effort rollback try/catches. If any step after the initial bunny.createPullZone fails (setEuMode, addHostname, enableFreeSsl, or the DB-insert), the just-created bunny zone is removed so the user can retry cleanly — except when the zone was adopted (already existed in the user's account; we leave their data alone). Happy path is byte-identical; 5 new unit tests cover rollback, adoption skip, and cleanup-failure-doesn't-mask-original. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
createPullZoneandaddCustomHostnameare multi-step flows: bunny.net call → optional EU-mode / hostname / DNS → DB row. If a step afterbunny.createPullZonefails, the zone was previously orphaned at bunny.net with no DB record — user retried, created another orphan.PullZoneResult.adopted) are explicitly not rolled back — they belong to the user and pre-date our work.Why pragmatic instead of saga / state machine
No DB migration, no schema change, happy path byte-identical. ~40 LOC of code change. Edge case where rollback itself fails is already covered by the implicit reconciliation in
getPullZoneStatusFn(deletes DB row when remote is gone,src/serverFunctions/pull-zone.ts:236-239).Test plan
npm test— 221 / 221 (was 216 / 216 + 5 new)npm run typecheck— cleannpm run code-check— cleanNew tests
createPullZonerolls back whensetEuModefailscreatePullZonerolls back whenaddHostnamefailscreatePullZonedoes not roll back whenadopted: truecreatePullZonecleanup failure does not mask the original erroraddCustomHostnamerolls backaddHostnamewhenenableFreeSslfailsFollow-up (separate PR)
🤖 Generated with Claude Code