Skip to content

fix(deployments): retire inactive-version side effects by row with bounded outbox continuation - #7405

Merged
icecrasher321 merged 2 commits into
stagingfrom
fix/outbox-inactive-deployment-cleanup
Sep 2, 2026
Merged

fix(deployments): retire inactive-version side effects by row with bounded outbox continuation#7405
icecrasher321 merged 2 commits into
stagingfrom
fix/outbox-inactive-deployment-cleanup

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

  • Post-activation cleanup of inactive deployment versions walked every version of the workflow with a dozen round trips each and only checkpointed after a full pass, so a workflow with hundreds of versions hit the 90s outbox handler timeout on every attempt, restarted from zero, and dead-lettered while holding the deploy request the whole time
  • Cleanup is now keyed by side-effect rows: one fenced statement deletes stale schedules, and stale webhooks drain in bounded batches of 20; the prepare handler yields a continuation while rows remain instead of timing out
  • Add continueOutboxHandler to the outbox service (defer without consuming an attempt) and use it at the existing bounded-continuation call sites
  • Legacy inactive/undeployed cleanup handlers honor the abort signal, so a timed-out attempt stops instead of running past its lease
  • Undeploy cleanup no longer walks the payload's version list; the field stays optional for one release of rolling compatibility
  • getProtectedDeploymentVersionId is the single query for the candidate version an in-flight operation is preparing; the boolean helper wraps it

Type of Change

  • Bug fix

Testing

  • bun run type-check, bun run lint, block-registry audit, and check:audits (45 audits) pass
  • Unit tests cover the continuation result, the fenced schedule delete, bounded webhook batches, the protected candidate version, and abort handling; the 21 dependent suites pass unchanged

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 2, 2026 7:23pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces deployment-version-by-version cleanup with bounded, row-oriented cleanup and adds non-attempt-consuming outbox continuations.

  • Deletes inactive deployment schedules in one fenced transaction while protecting an in-flight candidate.
  • Retires stale webhook subscriptions in bounded batches with per-row state checks.
  • Adds abort handling to legacy cleanup paths and retains optional legacy undeploy payload compatibility.
  • Reuses the continuation helper for existing bounded member and enterprise reconciliation handlers.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains established in the eligible follow-up scope.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/core/outbox/service.ts Introduces a named helper for bounded continuations that defer processing without consuming the event's attempt budget.
apps/sim/lib/webhooks/deploy.ts Adds bounded inactive-version webhook cleanup with provider teardown, per-row activation and candidate checks, and continuation signaling.
apps/sim/lib/workflows/deployment-outbox.ts Reworks inactive and undeployed side-effect cleanup around bounded row processing, checkpoints, continuations, and abort-aware execution.
apps/sim/lib/workflows/persistence/deployment-operations.ts Centralizes lookup of the deployment version protected by the current in-flight operation.
apps/sim/lib/workflows/schedules/deploy.ts Adds transactional bulk deletion of inactive deployment schedules while fencing superseded operations and protecting the current candidate.

Sequence Diagram

sequenceDiagram
    participant O as Outbox worker
    participant H as Deployment handler
    participant S as Schedule cleanup
    participant W as Webhook cleanup
    O->>H: Process cleanup event
    H->>S: Delete inactive schedules with fences
    S-->>H: Deleted or superseded
    H->>W: Retire up to 20 stale rows
    W-->>H: hasMore
    alt Rows remain
        H-->>O: Continue without consuming attempt
        O->>H: Retry after backoff
    else Cleanup complete
        H-->>O: Complete event
    end
Loading

Reviews (2): Last reviewed commit: "fix(deployments): fence webhook teardown..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 15 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/workflows/deployment-outbox.ts
Comment thread apps/sim/lib/workflows/deployment-outbox.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@icecrasher321 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 15 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@icecrasher321
icecrasher321 merged commit d48ee87 into staging Sep 2, 2026
29 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/outbox-inactive-deployment-cleanup branch September 2, 2026 19:34
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