Skip to content

fix(backend): cap unbounded findMany queries in summary and SSE subsc… - #1307

Merged
K1NGD4VID merged 3 commits into
LabsCrypt:mainfrom
Hikmaholadele:issue-1246
Aug 30, 2026
Merged

fix(backend): cap unbounded findMany queries in summary and SSE subsc…#1307
K1NGD4VID merged 3 commits into
LabsCrypt:mainfrom
Hikmaholadele:issue-1246

Conversation

@Hikmaholadele

Copy link
Copy Markdown
Contributor

Closes #1246
Summary

  • Add bounded stream queries to getUserStreamSummary and SSE subscribe
  • Prevent unbounded findMany calls from loading all streams for a wallet
  • Add tests verifying the configured stream cap is enforced
  • Preserve existing claimable-amount and SSE behavior within the bounded result set

Testing

  • Ran the relevant backend tests
  • Verified wallets with more streams than the cap are limited to the configured maximum

Hikmaholadele and others added 3 commits August 29, 2026 20:01
…ribe

Issue LabsCrypt#1246: Both getUserStreamSummary and SSE subscribe fetch all
streams for a wallet with no take limit, causing unbounded DB queries
when a wallet has thousands of streams.

- Add MAX_USER_STREAMS (500) cap to getUserStreamSummary with orderBy
  startTime desc so the most recent streams are always included
- Add MAX_SSE_STREAMS (500) cap to SSE subscribe with orderBy
  startTime desc
- Both queries now include a documented take limit and the summary
  response includes a truncated flag when the cap is hit
- Add tests proving a wallet with more streams than the cap only
  fetches up to the cap and the truncated flag is set correctly
- Existing claimable-amount calculation and SSE behavior remain correct
  within the bounded result set

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
…imports in stream controller test

The merge from main reverted the import line in stream.controller.test.ts,
dropping getUserStreamSummary and MAX_USER_STREAMS while keeping the test
cases that reference them. This caused TS2304 errors in the Backend CI
build and runtime ReferenceError in Backend npm test.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@K1NGD4VID
K1NGD4VID merged commit 80d7164 into LabsCrypt:main Aug 30, 2026
10 checks passed
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.

[Audit] Unbounded findMany queries with no pagination on hot paths

2 participants