Skip to content

fix(webhooks): skip duplicate webhook deliveries already in progress instead of polling - #8712

Merged
waleedlatif1 merged 6 commits into
stagingfrom
fix/webhook-duplicate-skip
Oct 7, 2026
Merged

waleedlatif1 merged 6 commits into
stagingfrom
fix/webhook-duplicate-skip

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • A duplicate webhook delivery whose idempotency key is already in progress used to poll every second until the original run finished (up to the 2h lease), holding a worker, a queue slot, and its usage reservation, even though nothing reads the duplicate job's result. It now returns immediately as a duplicate no-op and releases its reservation through the existing not-started path
  • Add executeOrSkipInProgress to the idempotency service (separate method, discriminated resolved | in-progress result) instead of an option, so a skipped duplicate can never be mistaken for an undefined result. executeWithIdempotency is unchanged for every other caller — Stripe billing webhooks and the polling triggers keep waiting (Stripe must not 2xx before the first attempt settles; polling counts gate cursor advancement)

Type of Change

  • Bug fix

Testing

  • New failure-mode tests, each shown red by reverting its guard: skip resolves without polling or running the operation; skip still replays completed and rethrows failed; webhook job returns duplicate without preprocessing/requeue and releases the slot once. A wait-path test guards that the default still waits (goes red if the default flips to skip)
  • bun run --cwd apps/sim test on idempotency, webhook-execution, and polling suites
  • bun run lint, bun run type-check, bun run check:audits — green

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 Oct 7, 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 Oct 7, 2026 1:59am UTC

Request Review

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

Fix all with cubic | Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/core/idempotency/service.ts Outdated
@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[High risk] Changes webhook delivery deduplication and idempotency polling.

The PR appears safe to merge, with no new actionable findings.

Summary

Webhook jobs now skip deliveries whose idempotency key is already in progress and release the duplicate job's reservation. Other callers keep waiting for the original result.

  • Adds executeOrSkipInProgress with separate resolved and in-progress outcomes.
  • Adds tests for skipping duplicates, replaying results, and preserving the default wait.
  • The only change since the previous review clarifies the lease limit in the documentation.
  • The earlier polling finding is fixed: pollingIdempotency no longer has the proposed five-minute lease. waleedlatif1 deferred bounding that lease to a separate change with renewal.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Webhook job] --> B[executeOrSkipInProgress]
  B --> C{Claim state}
  C -->|New claim| D[Run operation and save outcome]
  C -->|Completed| E[Replay saved result]
  C -->|Failed| F[Throw saved error]
  C -->|In progress| G[Release duplicate reservation]
  G --> H[Return duplicate no-op]
Loading

Reviews (6) · Last reviewed commit: "docs(idempotency): reflow executeWithIde..." · Reviewed by Greptile

Comment thread apps/sim/lib/core/idempotency/service.ts Outdated
@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 Oct 7, 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.

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

Confidence score: 5/5

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

Turn on auto-fix | 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 Oct 7, 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.

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

Confidence score: 5/5

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

Turn on auto-fix | 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 Oct 7, 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.

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

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

Fix all with cubic | Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/core/idempotency/service.ts Outdated
@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 Oct 7, 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

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 Oct 7, 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.

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

Confidence score: 5/5

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

Turn on auto-fix | Re-trigger cubic

@waleedlatif1 waleedlatif1 changed the title fix(webhooks): skip duplicate in-progress deliveries and bound the polling claim lease fix(webhooks): skip duplicate webhook deliveries already in progress instead of polling Oct 7, 2026
@waleedlatif1
waleedlatif1 merged commit ccce7f7 into staging Oct 7, 2026
34 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/webhook-duplicate-skip branch October 7, 2026 02:16

This branch was previously deployed

1 inactive deployment
Preview — 75b711db Deployed Oct 7, 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