fix: parse VALKEY_URL into RedisOptions for BullMQ — fixes ECONNREFUSED 6379 #336

Merged
jason.woltje merged 2 commits from fix/bullmq-valkey-url-port into main 2026-03-31 01:45:38 +00:00
Owner

Problem

BullMQ v5.71.0 RedisConnection constructor does:

Object.assign({ port: 6379, host: "127.0.0.1" }, opts)

When opts is a URL string ("redis://localhost:6380" via as unknown as ConnectionOptions), Object.assign only copies character-index properties from the string — the default port 6379 was never overridden, causing ECONNREFUSED 127.0.0.1:6379 on every startup despite VALKEY_URL=redis://localhost:6380 being set.

Fix

getConnection() in apps/gateway/src/queue/queue.service.ts now parses VALKEY_URL with new URL() and returns a plain { host, port, ... } RedisOptions object that Object.assign merges correctly.

Also includes

  • pnpm install was needed after monorepo consolidation (#331) added packages/forge — ran it and committed the missing plugins/macp prettier formatting that was blocking format:check.
## Problem BullMQ v5.71.0 `RedisConnection` constructor does: ```js Object.assign({ port: 6379, host: "127.0.0.1" }, opts) ``` When `opts` is a URL string (`"redis://localhost:6380"` via `as unknown as ConnectionOptions`), `Object.assign` only copies character-index properties from the string — the default port `6379` was never overridden, causing `ECONNREFUSED 127.0.0.1:6379` on every startup despite `VALKEY_URL=redis://localhost:6380` being set. ## Fix `getConnection()` in `apps/gateway/src/queue/queue.service.ts` now parses `VALKEY_URL` with `new URL()` and returns a plain `{ host, port, ... }` `RedisOptions` object that `Object.assign` merges correctly. ## Also includes - `pnpm install` was needed after monorepo consolidation (#331) added `packages/forge` — ran it and committed the missing `plugins/macp` prettier formatting that was blocking `format:check`.
jason.woltje added 2 commits 2026-03-31 01:45:06 +00:00
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.
style: fix prettier formatting in plugins/macp (consolidation follow-up)
Some checks failed
ci/woodpecker/pr/ci Pipeline failed
ci/woodpecker/push/ci Pipeline failed
1b317e8a0a
jason.woltje merged commit fa43989cd5 into main 2026-03-31 01:45:38 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaicstack/stack#336