Skip to content

feat(engine): aggregate delete failures during destroy instead of aborting - #973

Merged
sam-goodwin merged 2 commits into
mainfrom
claude/frosty-visvesvaraya-83b931
Jul 28, 2026
Merged

sam-goodwin merged 2 commits into
mainfrom
claude/frosty-visvesvaraya-83b931

Conversation

@sam-goodwin

@sam-goodwin sam-goodwin commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Builds on the aggregated-GC-failure work from #899: destroy already attempts every delete and aggregates failures; this PR makes the result a structured, typed aggregate and distinguishes blocked deletes from failed ones.

export class DestroyError extends Data.TaggedError("DestroyError")<{
  failures: ReadonlyArray<DeleteFailure>; // fqn, logicalId, resourceType, Cause
  blocked: ReadonlyArray<BlockedDelete>;  // skipped, with blockedBy: fqns
}> {}
  • Replaces the internal DependentDeletionFailed marker + raw combined Cause with outcome-typed delete effects (deleted | failed | blocked) and one DestroyError raised at the end (added to apply's declared error union).
  • A resource whose dependent failed to delete now reports skipped with a "blocked by <fqn>" session note and a structured blocked entry — instead of a fail status that conflates it with the real failure.
  • The replaced-row drain loop excludes failed/blocked FQNs per-row instead of stopping entirely on the first failed pass, so unaffected replacement chains keep draining.

Keeps #899's zombie-row provider guard and stripUnresolved(bindings) commit hygiene; its destroy-robustness.test.ts passes unchanged.

New engine tests (describe("error-aggregating destroy") in test/apply.test.ts): sibling survival + aggregate contents + recovery on re-destroy; a 3-deep chain where only the failing leaf is a failure and its upstream dependencies are blocked (delete never invoked); disjoint subtrees draining fully despite a failure elsewhere; replaced-row drain failure terminating with DestroyError instead of hanging.

🤖 Generated with Claude Code

sam-goodwin and others added 2 commits July 17, 2026 17:02
…rting

A single failed provider.delete used to abort the whole destroy phase,
stranding every not-yet-deleted resource — even ones whose deletes would
have succeeded (observed live: a Lambda delete failure left a CloudMap
namespace, its services, and a Route53 zone undeleted).

collectGarbage now attempts every delete in dependency order, catches
each failure without interrupting siblings, skips resources whose
dependent failed to delete (recorded as "blocked by", not a spurious
second error), keeps the replaced-row drain loop from re-spinning on
failed rows, and raises one typed DestroyError aggregate at the end so
the destroy still fails overall.

Co-Authored-By: Claude Fable 5 <[email protected]>
…araya-83b931

# Conflicts:
#	packages/alchemy/src/Apply.ts
@sam-goodwin
sam-goodwin merged commit cd6671e into main Jul 28, 2026
5 checks passed
@sam-goodwin
sam-goodwin deleted the claude/frosty-visvesvaraya-83b931 branch July 28, 2026 21:35
@alchemy-version-bot

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

alchemy

bun add alchemy@https://pkg.ing/alchemy/4cf9f19

@alchemy.run/better-auth

bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/4cf9f19

@alchemy.run/pr-package

bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/4cf9f19

DavidJFelix added a commit to DavidJFelix/alchemy-effect that referenced this pull request Aug 7, 2026
Resolves conflicts between the dashboard work (deployment journal in
apply, --ui deploy flow, delete-node pending reporting) and main's
Plan.destroy + aggregated destroy failures (alchemy-run#973), destroy stack-state
cleanup (alchemy-run#965), and local/live provider modes (alchemy-run#963):

- apply: keep the journal exit-mapping; run state.deleteStack after the
  deployment journal closes on a successful destroy
- collectGarbage: adopt main's outcome-based blocked/failed delete
  aggregation, keep the pending status report for queued deletions
- deploy/destroy/test harness: Plan.destroy + apply command option
- Cloudflare Workers ui: domains attr became singular domain
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