Skip to content

fix(queues): avoid ':' in BullMQ job ids (fixes #32)#33

Merged
productdevbook merged 1 commit intoproductdevbook:mainfrom
webparadoxer:fix/bullmq-job-id-colons
Apr 22, 2026
Merged

fix(queues): avoid ':' in BullMQ job ids (fixes #32)#33
productdevbook merged 1 commit intoproductdevbook:mainfrom
webparadoxer:fix/bullmq-job-id-colons

Conversation

@webparadoxer
Copy link
Copy Markdown
Contributor

Summary

Fixes #32sendNotification always fails with Custom Id cannot contain :.

BullMQ rejects custom jobIds containing : (it's the reserved Redis key separator). The notification queue was building ids with colons:

  • `fanout:${data.notificationId}` in `addFanoutNotificationJob`
  • `notification:${notificationId}:device:${deviceId}` and `notification:${notificationId}:channel:${channelId}:${to}` in `getSendNotificationJobId`

For channel/Web Push jobs, `to` is also an endpoint URL (`https://fcm.googleapis.com/...\`) — so colons leak in from there too.

Fix

  • Replace `:` with `-` as the separator in all custom job ids.
  • Sanitize colons out of the channel `to` segment before composing the id.
  • Update existing tests and add one that verifies a URL-shaped `to` never leaks a `:` into the id.

Test plan

  • `pnpm test` passes locally for the updated `notification-queue.test.ts`
  • Manual: `createApp` → `configureWebPush` → `registerDevice` (web) → `sendNotification { channelType: PUSH }` — previously failed with `Custom Id cannot contain :`, now succeeds and delivers.

Determinism (same id for same `(notificationId, deviceId)` / `(notificationId, channelId, to)` pair) is preserved, so BullMQ's dedup behavior is unchanged.

BullMQ throws `Custom Id cannot contain :` when a custom jobId contains
a colon (':' is a reserved Redis key separator). The notification queue
was using colons in both `fanout:<id>` and the device/channel job ids
built by `getSendNotificationJobId`, which caused `sendNotification` to
always fail with FAILED status. Channel 'to' values (e.g. Web Push
endpoint URLs like `https://fcm.googleapis.com/...`) also leaked colons
into the id.

Replace colons with hyphens in all custom job ids and sanitize the
channel 'to' segment. Closes productdevbook#32.
@webparadoxer
Copy link
Copy Markdown
Contributor Author

any updates?

@productdevbook productdevbook merged commit e716d79 into productdevbook:main Apr 22, 2026
1 check passed
@productdevbook
Copy link
Copy Markdown
Owner

Please excuse the delay. I’ve been busy publishing several npm package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sendNotification fails with 'Custom Id cannot contain :'

3 participants