Skip to content

Conversation

@aadamgough
Copy link
Contributor

Description

Gmail webhooks waited for the entire workflow before responding, so when workflows got longer Gmail would retry, causing duplications in workflow execution. The process is now asynchronous like the other webhooks, preventing the time-related duplicate executions.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I had two curl commands send identical requests with the second command sent 10 seconds after the first, while a 30 second workflow was still processing. This recreated the issue where the polling would timeout which would lead to duplicate triggers. After applying the fix, the first request responded quickly and started background processing, and the second request was caught and returned "duplicate request", which is expected behaviour.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • All tests pass locally and in CI (bun run test)
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have updated version numbers as needed (if needed)
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Security Considerations:

  • My changes do not introduce any new security vulnerabilities
  • I have considered the security implications of my changes

@vercel
Copy link

vercel bot commented Jun 26, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sim ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 26, 2025 6:12pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Jun 26, 2025 6:12pm

@delve-auditor
Copy link

delve-auditor bot commented Jun 26, 2025

No security or compliance issues detected. Reviewed everything up to 489514f.

Security Overview
  • 🔎 Scanned files: 1 changed file(s)
Detected Code Changes
Change Type Relevant files
Enhancement ► route.ts
    Move Gmail webhook processing to synchronous flow
    Add Gmail deduplication using generic method

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Modified Gmail webhook processing in apps/sim/app/api/webhooks/trigger/[path]/route.ts to handle requests asynchronously, preventing duplicate workflow executions caused by Gmail's timeout retries.

  • Changed Gmail webhook handling to return immediately while processing continues in background
  • Aligns Gmail webhook behavior with other webhook types for consistent response handling
  • Added safeguards against duplicate processing through request deduplication
  • Maintains existing security checks including webhook secret validation
  • Fixes issue where long-running workflows (>30s) triggered duplicate Gmail webhook executions

1 file reviewed, no comments
Edit PR Review Bot Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 0da8a70 into staging Jun 28, 2025
4 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/gmail-wh branch June 28, 2025 02:24
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
Co-authored-by: Adam Gough <adamgough@Adams-MacBook-Pro.local>
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.

3 participants