Skip to content

Commit 3c28514

Browse files
committed
update Redis connection options in queue configuration: set maxRetriesPerRequest to 10, enable TLS, and improve error handling.
1 parent 11c81ba commit 3c28514

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

src/lib/queue/config.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,26 @@ console.log("Redis connection configured (config.ts)");
1616
// Additional Redis connection options for Vercel deployment
1717
const redisOptions = {
1818
enableReadyCheck: false,
19-
maxRetriesPerRequest: 3, // Reduce from null (infinite) to 3 to avoid hanging
19+
maxRetriesPerRequest: 10, // Reduce from null (infinite) to 3 to avoid hanging
2020
// These options help with TLS connections often required by Redis providers
21-
tls:
22-
process.env.NODE_ENV === "production"
23-
? { rejectUnauthorized: false }
24-
: undefined,
21+
tls: { rejectUnauthorized: false },
2522
retryStrategy: (times: number) => {
2623
// Exponential backoff for connection retries
2724
return Math.min(times * 100, 3000);
2825
},
2926
// Add a connection timeout to avoid hanging indefinitely
3027
connectTimeout: 10000,
3128
// Add better error handling
32-
showFriendlyErrorStack: process.env.NODE_ENV !== "production",
29+
showFriendlyErrorStack: true,
30+
enableTLSForSentinelMode: false,
3331
};
3432

3533
// Bull requires specific Redis settings
3634
// DON'T pass the Redis client directly to Bull
3735
// Instead, pass the connection options
3836
export const queueOptions = {
3937
// For Vercel, we need to provide Redis options rather than just the URL
40-
redis:
41-
process.env.NODE_ENV === "production"
42-
? {
43-
port: 6379, // Default Redis port, will be overridden by URL if provided
44-
host: "127.0.0.1", // Default host, will be overridden
45-
password: undefined, // Will be extracted from URL
46-
...redisOptions,
47-
// Set this to your Redis URL if just passing options
48-
url: redisUrl,
49-
}
50-
: redisUrl,
38+
redis: redisUrl,
5139
defaultJobOptions: {
5240
attempts: 5, // Retry failed jobs 5 times
5341
backoff: {

0 commit comments

Comments
 (0)