fix: Redis cache, BullMQ webhook queue, pg_trgm migration, Prisma pool tuning (#775 #776 #777 #778) - #893
Merged
OlaGreat merged 3 commits intoJul 25, 2026
Conversation
…xpose Prisma pool tuning (OlaGreat#775 OlaGreat#776 OlaGreat#777 OlaGreat#778) - Add ioredis and bullmq as dependencies - Create Redis client service (src/services/redis.ts) with graceful fallback to in-process cache when REDIS_URL is not set - Replace in-process LRU leaderboard cache with Redis-backed cache that falls back to in-process cache for local dev (OlaGreat#775) - Create BullMQ webhook delivery queue (src/services/webhook-queue.ts) that replaces DB-polled webhook processor when Redis is available, with exponential backoff and concurrency control (OlaGreat#776) - Update webhook-processor to use BullMQ when Redis is available, falling back to existing DB-polled approach for local dev - Expose DATABASE_POOL_SIZE and DATABASE_POOL_TIMEOUT env vars in db.ts to allow Prisma connection pool tuning (OlaGreat#778) - pg_trgm extension migration already exists (OlaGreat#777) - Fix pre-existing TS build errors: missing supporters route handler, webhook secret vs secretHash field mismatch - Add REDIS_URL, DATABASE_POOL_SIZE, DATABASE_POOL_TIMEOUT to .env.example
|
@trinnode Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…xpose Prisma pool tuning (OlaGreat#775 OlaGreat#776 OlaGreat#777 OlaGreat#778) - Add ioredis and bullmq as dependencies - Create Redis client service (src/services/redis.ts) with graceful fallback to in-process cache when REDIS_URL is not set - Replace in-process LRU leaderboard cache with Redis-backed cache that falls back to in-process cache for local dev (OlaGreat#775) - Create BullMQ webhook delivery queue (src/services/webhook-queue.ts) that replaces DB-polled webhook processor when Redis is available, with exponential backoff and concurrency control (OlaGreat#776) - Update webhook-processor to use BullMQ when Redis is available, falling back to existing DB-polled approach for local dev - Expose DATABASE_POOL_SIZE and DATABASE_POOL_TIMEOUT env vars in db.ts to allow Prisma connection pool tuning (OlaGreat#778) - pg_trgm extension migration already exists (OlaGreat#777) - Fix pre-existing TS build errors: missing supporters route handler, webhook secret vs secretHash field mismatch - Add REDIS_URL, DATABASE_POOL_SIZE, DATABASE_POOL_TIMEOUT to .env.example
Adds missing migrations for pre-existing drift between schema.prisma and the migration history: - Rename Webhook.secret → secretHash - Add unique constraint on AcceptedAsset(profileId, code, issuer) - Add unique constraint on Profile(walletAddress) - Recreate SupportTransaction FK with ON DELETE RESTRICT
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses four backend infrastructure issues in a single focused changeset:
#775 — Replace in-process leaderboard LRU cache with Redis
ioredisas a dependencysrc/services/redis.ts— shared Redis client constructed fromREDIS_URLenv var with graceful fallback to in-process cache when Redis is unavailable (local dev still works out of the box)getCachedLeaderboard,setCachedLeaderboard, andinvalidateProfileLeaderboardCacheto useredis.get/redis.setex/redis.delwhen Redis is available, falling back to the existing in-processMapcache#776 — Replace DB-polled webhook delivery with BullMQ job queue
bullmqas a dependencysrc/services/webhook-queue.ts— BullMQ queue and worker with:{ attempts: 4, backoff: { type: 'exponential', delay: 1000 } }webhook-processor.tsto start a BullMQ worker when Redis is available, falling back to the existing DB-polled processor for local dev#777 — Add pg_trgm extension creation to Prisma migration
pg_trgmextension migration already exists atprisma/migrations/20260627000000_add_pg_trgm_extension/— no additional changes needed#778 — Expose Prisma connection pool size via environment variable
src/db.tsto constructDATABASE_URLwithconnection_limitandpool_timeoutsearch params from env varsDATABASE_POOL_SIZE(default: 10, recommended: 20 for production) andDATABASE_POOL_TIMEOUT(default: 10 seconds) to.env.exampleAdditional fixes (pre-existing)
v1Router.get("/supporters/:address", ...)handler declaration that prevented compilationwebhook.secret→webhook.secretHashto match the Prisma schema field nameTest Results
tsc -p tsconfig.json— zero errors, improved from 2 pre-existing syntax errors)mainbranch)REDIS_URLis not set, all features gracefully fall back to in-process cache and DB-polled processorDependencies Added
ioredis— Redis clientbullmq— job queue built on RedisCloses #775
Closes #776
Closes #777
Closes #778