[Backend] Fix the runway worker's unbounded loading and per-stream N+1 queries
Overview & Background
The runway worker loads all active streams in one unbounded query (stream-runway-worker.ts:148-153: findMany({ where: { isActive: true, isPaused: false } }) with no take/cursor), then calls wasAlertRecentlySent (alertHistory.findFirst) once or twice per stream, awaited serially. Memory grows with the number of active streams and each hourly run costs O(n) round-trips — the same class of problem the summary endpoint already fixed with MAX_USER_STREAMS. The stream: any parameter at line 26 also erases the Prisma type.
Technical Specification & Architecture
- Batch the dedup check (
groupBy/findManyonalertHistoryfor candidate IDs). - Page through streams with a cursor.
- Type
streamas the Prisma select result.
Target Files
backend/src/workers/stream-runway-worker.ts
Acceptance Criteria
- [ ] Query count per run is constant in the number of streams (per page), not O(n).
- [ ] No
anyon the stream parameter. - [ ] A test with a large stream set bounds query count.
@Aboyeji-Isaac has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
Hi maintainer, I would like to work on this issue. I understand the goal is a cash-flow calendar that visualizes expected incoming and outgoing stream activity over a selectable period, correctly accounting for pauses, end dates, and uncertainty so projections are never presented as guaranteed settlement. Based on my experience building financial timeline components in React/TypeScript with careful date and timezone handling, this is how I'll resolve this issue: I will build the calendar to expand each stream's schedule across the selected range while respecting pauses and end dates, reconcile per-day summaries against existing stream detail calculations, test timezone boundaries and failure cases, label projected amounts as estimates, update the relevant documentation, and open a PR referencing
Closes #263with test results, without touching wallet authorization, chain validation, accounting invariants, or secret handling.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Aboyeji-Isaac to this issue.
@anitahhhh has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
this is easy
ℹ️ Repo Maintainers: To accept this application, review their application or assign @anitahhhh to this issue.
Congratulations, @anitahhhh! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.
🧑💻 @anitahhhh: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
This issue has been completed by @anitahhhh as part of the Stellar Wave Program's 11th Wave 🥳
😎 @anitahhhh: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.