Skip to content

fix(notifications): match bigint notification ids in the listener - #103

Merged
dylanjeffers merged 1 commit into
mainfrom
fix/listener-bigint-notification-ids
Oct 6, 2026
Merged

dylanjeffers merged 1 commit into
mainfrom
fix/listener-bigint-notification-ids

Conversation

@dylanjeffers

Copy link
Copy Markdown
Contributor

Problem

The notifications listener drops every app notification. Prod logs show about 11k IDs a day under tick: some notification IDs were not found in DB, and zero Processing N app notifications lines in 24h.

The rows exist. I sampled 200 "missing" IDs from the logs and all 200 are in notification on the primary.

Cause: api migration 0233 (Fix notification ID sequence exhaustion, 2026-08-03) changed notification.id from integer to bigint. node-postgres returns bigint as a string. The tick builds byId from row.id (string) and looks it up with IDs from the NOTIFY payload (json_build_object → JS number), so byId.get(id) is always undefined.

Impact since the migration: app pushes are not sent for any type that goes through this listener (follows, reposts, saves, comments, tips, rewards, announcements and re-engagement campaigns). DMs use a separate path and are unaffected. Email digests read the DB directly and are unaffected by this bug.

Change

fetchNotificationsByIds and getNotificationById convert id to a number. That restores the pre-migration shape for everything downstream. IDs are about 3.3e9, far below 2^53.

Verification

I ran the tick's lookup against prod (read-only) on the 200 most recent notification IDs:

matched
current (row.id as key) 0 / 200
fixed (Number(row.id)) 200 / 200

tsc (only the existing unbuilt-workspace module errors), Prettier and eslint are clean. The one eslint warning is pre-existing on main.

Rollout note

Merging auto-deploys and turns app pushes back on for all types at once. There is no backlog replay: NOTIFY IDs are in-memory, so only notifications created after deploy are sent. After deploy, expect Processing N app notifications lines, and the not found warnings should drop to roughly zero.

🤖 Generated with Claude Code

api migration 0233 (2026-08-03) widened notification.id to bigint, which
pg returns as a string. The tick keys fetched rows by row.id and looks them
up with the numeric ids from the NOTIFY payload, so nothing matches: every
app notification is logged as "not found" and dropped. Normalize ids to
numbers where rows are fetched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dylanjeffers
dylanjeffers merged commit df7c6e7 into main Oct 6, 2026
2 checks passed
@dylanjeffers
dylanjeffers deleted the fix/listener-bigint-notification-ids branch October 6, 2026 00:28
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.

1 participant