🐞 Fix startup freeze in EmailQueueService during Redis connection #232
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.
The application was freezing during startup at "Creating marketing queue for region" when running in Docker environments, particularly after configuring SMTP services. This occurred because the BullMQ Worker constructor would hang indefinitely when Redis connections experienced delays or failures.
Root Cause
The issue was in the
EmailQueueService.initializeQueue()
method where:Solution
1. Redis Connection Resilience
connectTimeout: 10000
lazyConnect: true
for improved connection management2. Timeout Protection for Queue Initialization
initializeQueue()
asynchronous with 15-second timeout wrappercreateQueueAndWorkerWithTimeout()
method to prevent indefinite hangs3. Enhanced Error Handling
instrumentation.ts
to prevent app crashes4. Production Readiness
Testing
The fix ensures the application will either:
This is particularly important for Docker deployments where container networking can introduce connection delays.
Fixes #231.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
binaries.prisma.sh
node scripts/postinstall.js
(dns block)node /home/REDACTED/work/useSend/useSend/node_modules/.pnpm/@prisma+[email protected][email protected][email protected]/node_modules/@prisma/client/node_modules/.bin/../../../../../../[email protected][email protected]/node_modules/prisma/build/index.js -v
(dns block)googlechromelabs.github.io
node install.mjs
(dns block)https://storage.googleapis.com/chrome-for-testing-public/127.0.6533.88/linux64/chrome-linux64.zip
node install.mjs
(http block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.