Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

@icecrasher321 icecrasher321 commented Jul 16, 2025

Description

We will have the following Rate Limits
Screenshot 2025-07-16 at 1 51 34 PM

Features Added

  • RateLimiter: Enforces per-user rate limits based on subscription tier (see limits in image above)
  • Async Execution Mode: Added X-Execution-Mode: async header support for non-blocking workflow execution using Trigger.dev
  • Job Status API: /api/jobs/{jobId} endpoint to check execution status and retrieve results
  • Deploy Modal Examples: Added sync/async toggle with examples for job status checking and rate limit queries

Notes:
Synchronous Execution: Direct execution in API route for immediate results. System limits only protected by rate limits.
Rate Limiting: Applied to all non-manual trigger types (API, webhook, schedule)

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Test curling deployed APIs with async + sync. Write stress tests for different kinds of workflows.

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

@delve-auditor
Copy link

delve-auditor bot commented Jul 16, 2025

No security or compliance issues detected. Reviewed everything up to d0bbad5.

Security Overview
  • 🔎 Scanned files: 36 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

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.

@vercel vercel bot temporarily deployed to Preview – docs July 16, 2025 23:13 Inactive
@icecrasher321 icecrasher321 marked this pull request as ready for review July 16, 2025 23:25
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 infrastructure change to support asynchronous workflow execution with tiered rate limiting. The key components are:

  1. A job queuing system that allows workflows to be executed either synchronously (immediate results) or asynchronously (background processing)
  2. Rate limiting based on subscription tiers with different limits for sync/async execution
  3. New APIs for job status monitoring and rate limit checking
  4. Refactored instrumentation to properly handle different runtime environments

The implementation includes proper database migrations, atomic operations for job state changes, comprehensive error handling, and extensive test coverage. The system is designed to prevent resource exhaustion while providing differentiated service levels based on subscription tiers.

Confidence score: 5/5

  1. This PR is very safe to merge due to its comprehensive test coverage and careful handling of edge cases
  2. The code shows excellent attention to detail in areas like atomic operations, error handling, and proper resource cleanup
  3. The migration files and queue management code deserve extra attention during review due to their critical nature

23 files reviewed, 26 comments
Edit PR Review Bot Settings | Greptile

const logger = createLogger('EdgeInstrumentation')

export async function register() {
console.log('[Edge Instrumentation] register() called')
Copy link
Contributor

Choose a reason for hiding this comment

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

style: using console.log here while logger.info is used below - should be consistent

@vercel vercel bot temporarily deployed to Preview – docs July 18, 2025 03:02 Inactive
@vercel vercel bot temporarily deployed to Preview – docs July 18, 2025 19:35 Inactive
@icecrasher321 icecrasher321 merged commit b05a9b1 into staging Jul 18, 2025
6 checks passed
}
}

// TODO: Implement task cancellation via Trigger.dev API if needed
Copy link
Collaborator

Choose a reason for hiding this comment

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

@icecrasher321 remove this

@@ -1,9 +1,32 @@
export async function register() {
console.log('[Main Instrumentation] register() called, environment:', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove the logging here since it'll crowd the logs and is only useful for our debugging

@waleedlatif1 waleedlatif1 deleted the feat/execution-queuing-system branch July 22, 2025 19:57
arenadeveloper02 pushed a commit to arenadeveloper02/p2-sim that referenced this pull request Sep 19, 2025
…n tier (simstudioai#702)

* v1 queuing system

* working async queue

* working impl of sync + async request formats

* fix tests

* fix rate limit calc

* fix rate limiting issues

* regen migration

* fix test

* fix instrumentation script issues

* remove use workflow queue env var

* make modal have async examples

* Remove conflicting 54th migration before merging staging

* new migration files

* remove console log

* update modal correctly

* working sync executor

* works for sync

* remove useless stats endpoint

* fix tests

* add sync exec timeout

* working impl with cron job

* migrate to trigger.dev

* remove migration

* remove unused code

* update readme

* restructure jobs API response

* add logging for async execs

* improvement: example ui/ux

* use getBaseUrl() func

---------

Co-authored-by: Waleed Latif <walif6@gmail.com>
Co-authored-by: Emir Karabeg <emirkarabeg@berkeley.edu>
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.

4 participants