Repository navigation
fix(pulse): stop the catch-up sweep from pulsing manual and backfill runs - #774
Merged
Merged
Conversation
…runs The pulse trigger only ever fires for cron runs, so a manual run is not a missed pulse to recover. The sweep did not check the run source, so every new brand's onboarding run (deliberately unpulsed) was "recovered" at the start of the next daily cycle — and the brand's own first daily run pulsed an hour or two later, delivering two emails on the first morning.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every newly added brand received two Daily Pulse emails on its first morning: one at the very start of the daily cycle (~02:00 UTC) and one when its own daily run completed an hour or two later. From the second day on, only one arrived — which pointed straight at something that only runs once per run history.
Root cause: the catch-up sweep (
runPulseCatchUp) recovers pulses for completed tracking runs that have no pulse row after them, but it never checked the run'ssource. The onboarding run a brand performs on creation is a full, stamped run withsource: 'manual'— and it is deliberately unpulsed (the pulse trigger injob-runnerskips immediate/manual runs). The sweep couldn't tell "skipped on purpose" from "missed", so at the start of the next daily cycle it "recovered" the onboarding run as a pulse dated to the creation day. The brand's own first cron run then pulsed normally the same morning with a different window key, so the #701 same-window guard (correctly) saw two different runs and let both through.Confirmed against production data: 8 of the 9 brands created in the last week show the exact signature — first pulse at 02:00–02:01 with
pulse_date= creation day and a window anchored to the onboarding run's completion time, second pulse later the same morning from the brand's own run.The fix scopes the sweep to
source = 'cron'runs: the pulse trigger only ever fires for cron runs, so only cron runs can have a missed pulse. This also excludesbackfillruns. The sweep's actual job — recovering cron pulses eaten by a deploy/crash — is unchanged, and brands still get no email on the day they are created (existing intended behavior).Related issue
None — reported directly.
Type of change
fix— Bug fixHow to test
cd server && yarn test— newrunPulseCatchUptests cover both directions: manual/backfill runs are never considered, cron runs still are.Checklist
feature/,fix/,chore/,docs/)yarn lintpasses (server)yarn format:checkpasses (server)yarn testpasses (server, 384 tests)🤖 Generated with Claude Code