Skip to content

events: use the caller's clock in markDuplicates (fixes red CI) - #13

Open
Mathyaszzz wants to merge 1 commit into
TigerAppsOrg:mainfrom
Mathyaszzz:fix/mark-duplicates-clock
Open

Mathyaszzz wants to merge 1 commit into
TigerAppsOrg:mainfrom
Mathyaszzz:fix/mark-duplicates-clock

Conversation

@Mathyaszzz

Copy link
Copy Markdown

Problem
CI has failed on every PR since late September, including all 9 open dependabot bumps. The failing test is reminder emails for the same event collapse to the first announcement (2 !== 1, pipeline.test.ts:65).

Root cause
The test pins its clock to 2026-09-28 through ingestMessage's now option. markDuplicates ignored that and filtered on Postgres now(), so once the real date passed Sept 29 the event fell outside the one-day window and was never marked as a duplicate.

Fix
markDuplicates takes an optional now (defaults to the current time), and ingestMessage passes its own through. I fixed the function instead of moving the test's dates, since otherwise the next test that injects a clock would hit the same thing.

Testing
Locally against Postgres 17 with TEST_DATABASE_URL set:

  • Before (main): 24 pass, 1 fail (2 !== 1)
  • After: 25 of 25 pass, npm run check clean

Risk
Low. No production caller passes now, so production still uses the current time; the only difference is that it now comes from the app server's clock instead of the database's. syncMpuEvents is unchanged.

markDuplicates filtered on Postgres now(), ignoring the `now` that
ingestMessage accepts. The reminder-collapse test pins its clock to
2026-09-28, so once the real date passed 2026-09-29 the event fell out
of the one-day window and the test failed (2 !== 1). That is why CI has
been red on every PR since then, including all the dependabot bumps.

markDuplicates now takes an optional `now` (default: the current time)
and ingestMessage passes its own through. syncMpuEvents is unchanged and
keeps using the current time.
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