fix(server): poller correctness — stale-market alerts, overlapping ticks, live poll interval #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/poller-stale-and-overlap"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes three Important findings from the repo-wide review:
Stale/expiring markets no longer fire market alerts or vote in trends.
getScannerRows()returns every market with a snapshot; markets that drop out of discovery keep a frozendelta15m, which re-fired a market alert every cooldown window for up to retentionDays and biased symbol trends.runTicknow filters both consumers to the active discovery set, and the expiry guard (previously trends-only) also gates market-alert input — settlement convergence is not a repricing signal. Scanner SSE output is unchanged (stale markets stay visible).Poll ticks can no longer overlap. Replaced both
setIntervals with self-reschedulingsetTimeoutloops: the next run is scheduled only after the current one completes, eliminating duplicate snapshots and the read-then-write races in alert dedup/cooldown state when a slow upstream call outlasts the 8s interval.startPoller/stopPollerAPI unchanged; stop cancels pending timers.settings.pollIntervalMsnow takes effect. It was editable via PUT /api/settings but the poller captured the env value at startup — the only settings field not read live. The tick loop now reads the interval from the settings store when scheduling each next tick.Each fix has a regression test that reproduced the bug before the change (TDD red/green). Server suite 199 tests green; full repo 298 tests green; typecheck clean.
82bdd62569to236cd9005b