Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Jul 28, 2025

Description

Move webhook executions to trigger dev to enable immediate acks and make it follow standard async execution path.

  • Add webhook execution task
  • Fix server side usage checks for trigger dev executions in general
  • Add rate limit check to chat executions

Type of change

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

How Has This Been Tested?

Screen.Recording.2025-07-28.at.1.00.51.PM.mov

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 Jul 28, 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 Jul 28, 2025 7:28pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Skipped (Inspect) Jul 28, 2025 7:28pm

@icecrasher321 icecrasher321 changed the title improvement(webhooks): move webhook exeucution to trigger dev improvement(webhooks): move webhook exeucution to trigger.dev Jul 28, 2025
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.

Greptile Summary

This PR implements a significant architectural change to webhook processing by moving from synchronous to asynchronous execution using trigger.dev. The main change introduces a new webhook-execution.ts trigger task that handles webhook processing in the background, while the webhook endpoint now immediately acknowledges requests and queues them for async processing.

The refactoring involves several key components:

  1. New Trigger Task: apps/sim/trigger/webhook-execution.ts creates a new trigger.dev task that handles the actual webhook processing, including usage limit validation, input formatting for different providers (WhatsApp, Airtable, Telegram, etc.), and workflow execution with proper logging.

  2. Simplified Webhook Route: The webhook route handler in apps/sim/app/api/webhooks/trigger/[path]/route.ts has been streamlined to focus on immediate validation (signature verification, challenges) and task queuing, removing complex deduplication logic and direct workflow execution.

  3. Utility Function Refactoring: apps/sim/lib/webhooks/utils.ts has been simplified by removing execution-related functions and keeping only formatting, validation, and data processing utilities. The Airtable processing function now returns input data instead of executing workflows directly.

  4. Enhanced Chat Controls: Server-side usage limit checks have been added to chat execution in apps/sim/app/api/chat/utils.ts to prevent users from exceeding billing limits.

This architectural change follows webhook best practices by providing immediate acknowledgments (preventing provider retries due to timeouts) while ensuring reliable background processing. The implementation aligns webhook execution with the existing async workflow execution pattern used elsewhere in the codebase.

Confidence score: 3/5

• This change has moderate risk due to significant architectural refactoring of webhook processing logic
• Score reflects concerns about code duplication between webhook and workflow execution tasks, potential inconsistencies in error handling patterns, and untested status mentioned in PR description
• Files apps/sim/trigger/webhook-execution.ts and apps/sim/app/api/webhooks/trigger/[path]/route.ts need more attention due to core execution logic changes and potential edge cases

4 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

@vercel vercel bot temporarily deployed to Preview – docs July 28, 2025 19:24 Inactive
@icecrasher321 icecrasher321 merged commit 95efae9 into staging Jul 28, 2025
5 checks passed
@waleedlatif1 waleedlatif1 deleted the improvement/webhook-execution-async branch July 29, 2025 02:50
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…dioai#810)

* improvement(webhooks): move webhook exeucution to trigger dev

* remove old tests
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.

2 participants