Skip to content

fix: rate limiter cleanup, supabase pool, retry logic, remove dead code#448

Merged
PRODHOSH merged 2 commits into
PRODHOSH:mainfrom
DebasmitaBose0:feat/422-rate-limiter-fix
Jul 14, 2026
Merged

fix: rate limiter cleanup, supabase pool, retry logic, remove dead code#448
PRODHOSH merged 2 commits into
PRODHOSH:mainfrom
DebasmitaBose0:feat/422-rate-limiter-fix

Conversation

@DebasmitaBose0

@DebasmitaBose0 DebasmitaBose0 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Closes #422

Summary

Fixes in-memory rate limiter memory leak, adds Supabase connection pooling, adds retry logic to GitHub API calls, and removes dead code.

Changes

  • src/app/api/v1/users/[username]/route.ts — periodic cleanup interval (60s) evicts stale rate-limit entries; lazy Map initialization
  • src/lib/supabase.ts — added POOL_CONFIG with db.pool settings (min:0, max:5, timeouts)
  • src/lib/github.ts — added exponential backoff retry (3 attempts, 1s-10s delay) for 429/5xx/timeout
  • src/lib/validators/api.ts — removed unused validateEmail, sanitizeObject, COMMON_SCHEMAS
  • src/lib/env.ts — removed unused validatePublicEnv, validateServerEnv, getEnvWarning, isDev
  • src/lib/score.ts — removed unused getScoreDeltaPercentage
  • src/lib/fetch-with-timeout.ts — removed unused isTimeoutError

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of GitHub data retrieval by retrying temporary service errors, rate limits, timeouts, and transient API failures.
    • Improved rate-limit memory management for public profile requests.
  • Improvements

    • Enhanced Supabase connection handling for better serverless performance.
    • Simplified configuration checks for Supabase setup.
  • Refactor

    • Removed unused internal helpers and legacy environment validation behavior.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 10ce5013-8fb1-4921-b34f-1b3ace1e5946

📥 Commits

Reviewing files that changed from the base of the PR and between e877538 and 8d406cb.

📒 Files selected for processing (7)
  • src/app/api/v1/users/[username]/route.ts
  • src/lib/env.ts
  • src/lib/fetch-with-timeout.ts
  • src/lib/github.ts
  • src/lib/score.ts
  • src/lib/supabase.ts
  • src/lib/validators/api.ts

📝 Walkthrough

Walkthrough

The changes improve rate-limit memory cleanup, add retries and backoff to GitHub GraphQL requests, configure Supabase connection pooling, simplify environment detection, and remove unused shared utility exports and imports.

Changes

Runtime resilience and utility cleanup

Layer / File(s) Summary
Rate-limit memory management
src/app/api/v1/users/[username]/route.ts
Rate-limit hit tracking is lazily initialized, periodically cleaned up, and still enforces capacity and request-window limits.
GitHub GraphQL retry flow
src/lib/github.ts, src/lib/fetch-with-timeout.ts
GraphQL requests retry selected HTTP, GraphQL, and timeout failures with exponential backoff; the timeout helper is no longer exported.
Supabase configuration and pooling
src/lib/env.ts, src/lib/supabase.ts
Supabase configuration detection is simplified, and user/admin clients receive shared pool settings.
Shared utility API cleanup
src/lib/score.ts, src/lib/validators/api.ts
The score delta helper and unused validator imports are removed.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant githubGraphQL
  participant fetchWithTimeout
  participant GitHubGraphQLAPI
  participant sleep
  githubGraphQL->>fetchWithTimeout: send GraphQL request
  fetchWithTimeout->>GitHubGraphQLAPI: HTTP request
  GitHubGraphQLAPI-->>fetchWithTimeout: response or timeout
  githubGraphQL->>sleep: wait with exponential backoff
  githubGraphQL->>fetchWithTimeout: retry request
Loading

Possibly related PRs

Suggested labels: VETERAN

Suggested reviewers: babin123456, sakethsumanbathini, prodhosh

Poem

I’m a rabbit tuning routes at night,
With retry hops and pools just right.
Expired hits fade from the map,
GitHub gets a backoff nap.
Clean helpers bound with cheer—
A tidy burrow for the year!

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added frontend Related to UI / Next.js backend Supabase / API / database labels Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Welcome to OSSfolio, @DebasmitaBose0! 🎉

Thank you for opening this pull request and contributing to the open-source community! 🚀

To ensure a smooth review process, please make sure you have:

  • Checked that your changes work locally and compile cleanly.
  • Followed the guidelines outlined in CONTRIBUTING.md.
  • Linked your PR to an open issue (e.g. Closes #ISSUE_NUMBER).

We will review your PR as soon as possible. Happy coding! 💻✨

@PRODHOSH PRODHOSH self-requested a review July 14, 2026 03:10
@PRODHOSH PRODHOSH added ELUSOC ELUSOC project submission completed ADVENTURER Intermediate — 25 pts labels Jul 14, 2026
@PRODHOSH PRODHOSH merged commit 36e2f4f into PRODHOSH:main Jul 14, 2026
4 of 8 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Your PR just got merged, @DebasmitaBose0 — thank you for contributing to OSSfolio!

Your work is now part of the project. Here's what to do next:

  • ⭐ If you haven't already, consider giving the repo a star — it helps us grow.
  • 📢 Share your contribution on LinkedIn, Twitter, or wherever you hang out. You shipped open source!
  • 🔍 Browse other open issues if you want to keep contributing.

We really appreciate you taking the time. See you in the next PR! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ADVENTURER Intermediate — 25 pts backend Supabase / API / database completed ELUSOC ELUSOC project submission frontend Related to UI / Next.js

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ELUSOC] Rate Limiter Memory Leak & Connection Pooling

2 participants