Skip to main content

Overview

The reset() method removes a rate limit’s state from the database, allowing the next request to start fresh with full capacity.

Using the reset() Method

From src/client/index.ts:147-166:

When to Reset Rate Limits

1. Successful Login After Failed Attempts

The most common use case is resetting failed login attempts after a successful login:
From the README:
“Reset a rate limit on successful login”

2. Admin Override

Allow admins to manually reset rate limits for specific users:

3. Account Upgrades

Reset limits when a user upgrades their account:

4. Testing and Development

Reset limits in test code to ensure clean state:

Real Example from Source Code

From example/convex/example.ts:106-129:

Resetting Specific Keys vs Global

Reset the rate limit for a specific user/key:
This only affects the specified key. Other users’ rate limits are unaffected.

Sharding Behavior

From the documentation:
“Reset a rate limit to reset, including all shards.”
When you reset a rate limit that uses sharding, all shards are reset:

Fixed Window Behavior

From the documentation:
“Note: In the case of a fixed window without a specified start, the new window will be a random time.”
When you reset a fixed window rate limit:
  • If the config specifies a start time, the window aligns to that
  • If no start is specified, a new random start time is chosen
This helps prevent thundering herd issues:

What Happens After Reset

After calling reset(), the rate limit behaves as if it was never used:

Best Practices

For security-sensitive operations like login attempts, only reset after confirming success:
Keep an audit trail of when limits are reset:
Be careful about providing reset functionality to users for security-critical limits:
Instead of full reset, you might want to just add capacity:

Common Patterns

Password Reset Flow

Free Trial to Paid Conversion

Next Steps