Skip to content

fix(limits): updated rate limiter to match execution timeouts, adjusted timeouts fallback to be free plan#3136

Merged
waleedlatif1 merged 2 commits intostagingfrom
fix/limits
Feb 4, 2026
Merged

fix(limits): updated rate limiter to match execution timeouts, adjusted timeouts fallback to be free plan#3136
waleedlatif1 merged 2 commits intostagingfrom
fix/limits

Conversation

@waleedlatif1
Copy link
Collaborator

@waleedlatif1 waleedlatif1 commented Feb 4, 2026

Summary

  • updated rate limiter to match execution timeouts interfaces
  • adjusted timeouts fallback to be free plan instead of enterprise plan for consistency
  • updated tests
  • upgraded turborepo

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Cursor Bugbot reviewed your changes and found no issues for commit bf02231

@vercel
Copy link

vercel bot commented Feb 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Feb 4, 2026 11:23pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 4, 2026

Greptile Overview

Greptile Summary

This PR addresses timeout and rate limit consistency by aligning both systems to use free plan defaults when billing is disabled.

Key Changes:

  • Execution Timeouts: Simplified fallback logic to consistently return free plan timeouts when billing is disabled, removing the conditional check that previously returned enterprise timeouts
  • Rate Limiter: Added new getRateLimit() function that centralizes rate limit retrieval and respects isBillingEnabled flag, matching the pattern used in execution timeouts
  • Code Quality: Removed duplicate helper methods (getBucketConfig, createUnlimitedStatus) in RateLimiter class by using the centralized getRateLimit() function
  • Testing: Added mock for isBillingEnabled feature flag to ensure tests run with billing enabled
  • Dependencies: Upgraded turborepo from 2.8.0 to 2.8.3

The changes improve consistency between execution timeouts and rate limiting, ensuring both systems behave predictably when billing is disabled.

Confidence Score: 5/5

  • This PR is safe to merge with no identified issues
  • The changes are well-structured refactorings that improve code consistency and maintainability. The logic changes align execution timeouts and rate limiting behavior when billing is disabled. Tests have been updated appropriately to handle the new feature flag dependency.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/lib/core/execution-limits/types.ts Simplified timeout fallback logic to consistently use free plan when billing is disabled
apps/sim/lib/core/rate-limiter/types.ts Added getRateLimit function to centralize rate limit retrieval with isBillingEnabled check
apps/sim/lib/core/rate-limiter/rate-limiter.ts Refactored to use centralized getRateLimit function, removed duplicate helper methods
apps/sim/lib/core/rate-limiter/rate-limiter.test.ts Added mock for isBillingEnabled feature flag to ensure tests run with billing enabled

Sequence Diagram

sequenceDiagram
    participant Client
    participant RateLimiter
    participant getRateLimit
    participant FeatureFlags
    participant Storage

    Client->>RateLimiter: checkRateLimitWithSubscription(userId, subscription, triggerType, isAsync)
    
    alt triggerType === 'manual'
        RateLimiter-->>Client: return unlimited result
    else
        RateLimiter->>RateLimiter: determine plan (subscription?.plan || 'free')
        RateLimiter->>RateLimiter: getCounterType(triggerType, isAsync)
        RateLimiter->>getRateLimit: getRateLimit(plan, counterType)
        getRateLimit->>getRateLimit: toConfigKey(counterType)
        getRateLimit->>FeatureFlags: check isBillingEnabled
        
        alt !isBillingEnabled
            getRateLimit-->>RateLimiter: return RATE_LIMITS.free[key]
        else
            getRateLimit-->>RateLimiter: return RATE_LIMITS[plan || 'free'][key]
        end
        
        RateLimiter->>Storage: consumeTokens(storageKey, 1, config)
        Storage-->>RateLimiter: ConsumeResult
        RateLimiter-->>Client: return RateLimitResult
    end
Loading

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.

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 793adda into staging Feb 4, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/limits branch February 4, 2026 23:31
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