Skip to content

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

Open
Hikmaholadele wants to merge 2 commits into
LabsCrypt:mainfrom
Hikmaholadele:issue-1246
Open

fix(backend): cap unbounded findMany queries in summary and SSE subsc…#1307
Hikmaholadele wants to merge 2 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 2 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 <[email protected]>
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

1 participant