Repository navigation
fix(pulse): wait for the brand's Cloro queue to drain before computing - #570
Merged
Merged
Conversation
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
Daily Pulse emails could carry partial-window numbers that contradicted the dashboard. In webhook mode a tracking job can "complete" while Cloro is still delivering results: the worker's drain loop gives up after 10 minutes without progress (40 polls × 15s), but Cloro's real delivery latency is 30–80 minutes. The pulse trigger fires on job completion, so on days when the stall-abort hit, the digest was computed from whatever had landed by then — in one observed run, 859 of the day's results arrived after the pulse went out, and the emailed visibility rate differed from the dashboard by 5 points.
Fix:
generatePulseForBrandnow waits for the brand'scloro_pending_tasksqueue to drain before computing (60s poll, 90-minute cap so an orphaned task row can't block the pulse forever —cleanupStalePendingTaskssweeps those after 2h). The metrics window anchors to the actual compute time after the wait. The engine already runs fire-and-forget off the job runner, so waiting holds no tracking concurrency slot.Verified on the test brand: after the fix, the regenerated pulse matches the dashboard exactly for the same window.
Related issue
—
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cloro_pending_tasksrows present for a brand, triggernode src/scripts/test-pulse.js <brandId>— the engine polls until the queue drains, then computes.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)