Skip to content

Rate limiting#791

Merged
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
innovativedesign-lab:rate-limiting
Jun 27, 2026
Merged

Rate limiting#791
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
innovativedesign-lab:rate-limiting

Conversation

@innovativedesign-lab

Copy link
Copy Markdown
Contributor

Close: #766

Description

Here's a summary of the complete spec:

Design (design.md)
The approach uses a strategy pattern — an IRateLimiterStore interface with two implementations:

InMemoryStore — the existing Map logic, used in dev/test and as a production fallback
UpstashStore — wraps @upstash/ratelimit SlidingWindow over Redis, used in production when env vars are set withRateLimit() stays synchronous and unchanged (zero call-site breakage). A new withRateLimitAsync() is the distributed-capable function that route handlers migrate to incrementally. The key insight: making withRateLimit async would silently break every call site since if (rateLimitResponse) would always be truthy on an unawaited Promise — a complete silent outage.

Tasks (tasks.md) — 8 tasks in 5 waves:

Wave Tasks
1 Install @upstash/ratelimit + @upstash/redis · Document env vars in .env.example
2 Extract InMemoryStore + IRateLimiterStore from existing code
3 Implement UpstashStore with fail-open error handling
4 Implement createStore() factory + withRateLimitAsync()
5 Migrate 25 call sites · Verify existing tests pass · Add distributed tests
Ready to implement? You can click "Start Task" on any task, or ask me to begin.

Related Issue

Closes #766

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • No console errors
  • Uses Lucide icons consistently
  • Responsive design implemented
  • Starknet best practices followed

@innovativedesign-lab

Copy link
Copy Markdown
Contributor Author

Close: #791

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Close: #776

@RUKAYAT-CODER RUKAYAT-CODER merged commit 2619389 into rinafcode:main Jun 27, 2026
4 checks passed
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.

[Enhancement] Rate limiting is in-memory only — fails silently in multi-server and edge deployments

2 participants