Skip to content

fix(execution): publish a pause only after its run log is finalized - #8446

Merged
waleedlatif1 merged 3 commits into
stagingfrom
fix/pause-publish-after-log-finalize
Sep 30, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
fix/pause-publish-after-log-finalize

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • executeWorkflowCore finalizes the run log (running → redacting → pending) in a background post-execution promise, and callers published the pause right after, so a pause could be resumable while its log was still running
  • A resume arriving in that window was admitted, then rejected at the log claim (claimResumeExecutionLog accepts only pending/paused) with a non-retryable ResumeAdmissionError: Execution can no longer be resumed; a timed-wait auto-resume that lost the race was parked as intervention_required with no retry
  • handlePostExecutionPauseState now awaits waitForPostExecution() before publishing a pause. It is the single path every initial-run entry point takes (sync/SSE execute routes, v2 execute service, executeWorkflow, background workflow/schedule/webhook), and matches the resume path, which already settles its log before persisting a re-pause
  • If the paused log was never persisted (primary and fallback writes both failed), the run is failed via markAsFailed instead of publishing a pause no resume could claim
  • Complementary to fix(v2): await run log finalization before sync execute responds #8369, which applies the same settle-before-respond rule to completed sync runs

Type of Change

  • Bug fix

Testing

  • New real-Postgres pause-persistence.integration.ts (2 cases):
    • holds the log finalizer open and records, at the moment the pause is published, whether the log was finalized; then asserts the log is pending and an immediate resume is admitted
    • a finalizer that never persisted the log fails the run and publishes no pause
  • Original code: both cases red ([false] at publish; log left running). Each guard reverted on its own turns its case red; green with the fix
  • Existing caller suites: webhook/workflow/schedule execution, both execute routes, execute-workflow, execute-service, human-in-the-loop-manager — 248 passed
  • bun run type-check, bun run lint, block-registry check, bun run check:audits, docs-manifest:check

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • 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 30, 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 30, 2026 3:09am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High risk] Changes when pause state is published to the database.

The PR appears safe to merge; no outstanding findings remain.

Summary

The PR waits for paused-run log finalization before publishing a resumable pause, fails runs whose paused log was not persisted, and adds PostgreSQL integration coverage. The latest change replaces test-hook mock restoration with restoration scoped to the publication test.

Diagram
sequenceDiagram
  participant Core as Execution core
  participant Log as Run log
  participant Handler as Pause handler
  participant Pause as Pause store
  Core-->>Handler: Paused result
  Handler->>Log: Wait for finalization
  alt Log finalized
    Log-->>Handler: Claimable paused log
    Handler->>Pause: Publish pause
  else Log not finalized
    Log-->>Handler: No persisted completion
    Handler->>Log: Mark run failed
  end
Loading

Reviews (3) · Last reviewed commit: "fix(execution): restore the publish spy ..."

Comment thread apps/sim/lib/workflows/executor/pause-persistence.ts
Comment thread apps/sim/lib/workflows/executor/pause-persistence.integration.ts Outdated

@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 2 files

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

Fix all with cubic | Re-trigger cubic

Comment thread apps/sim/lib/workflows/executor/pause-persistence.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

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

Comment thread apps/sim/lib/workflows/executor/pause-persistence.integration.ts Outdated

@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 2 files

Confidence score: 5/5

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

Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

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

@waleedlatif1
waleedlatif1 merged commit ac49d38 into staging Sep 30, 2026
23 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/pause-publish-after-log-finalize branch September 30, 2026 03:10

This branch was previously deployed

1 inactive deployment
Preview — 81b2e99f Deployed Sep 30, 2026 by vercel[bot]
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