fix: parse VALKEY_URL into RedisOptions for BullMQ — fixes ECONNREFUSED 6379 #336
Reference in New Issue
Block a user
Delete Branch "fix/bullmq-valkey-url-port"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
BullMQ v5.71.0
RedisConnectionconstructor does:When
optsis a URL string ("redis://localhost:6380"viaas unknown as ConnectionOptions),Object.assignonly copies character-index properties from the string — the default port6379was never overridden, causingECONNREFUSED 127.0.0.1:6379on every startup despiteVALKEY_URL=redis://localhost:6380being set.Fix
getConnection()inapps/gateway/src/queue/queue.service.tsnow parsesVALKEY_URLwithnew URL()and returns a plain{ host, port, ... }RedisOptionsobject thatObject.assignmerges correctly.Also includes
pnpm installwas needed after monorepo consolidation (#331) addedpackages/forge— ran it and committed the missingplugins/macpprettier formatting that was blockingformat:check.BullMQ v5 RedisConnection constructor does: Object.assign({ port: 6379, host: '127.0.0.1' }, opts) When opts is a URL string (via 'as unknown as ConnectionOptions'), Object.assign only copies character-index properties from the string, so the default port 6379 was never overridden — causing ECONNREFUSED against the wrong port instead of the configured 6380. Fix: parse VALKEY_URL with new URL() and return a plain RedisOptions object { host, port, ... } so Object.assign merges it correctly.