audit: 2026-05-30 full-codebase audit — report, issues, docs, runbooks
Full-codebase-audit 2026-05-30 outputs: - Audit report: 09 - Audits/Full Codebase Audit - 2026-05-30.md - 81 issue files ISSUE-055..135 (decisions + 1 skipped no-brainer). - Scanner docs from scratch (was zero): architecture, data model, API ref, payment flow, operations runbook + repo README. - Doc-sync updates across API reference, data models, flows, design system. - Secret Rotation Runbook (08 - Operations) for the exposed credentials. - Reusable workflow guide (07 - Development) + .claude/workflows/full-codebase-audit.js. Issues remain status:open intentionally — the code fixes are uncommitted-then-committed working-tree changes per repo and aren't "resolved" until merged/deployed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
---
|
||||
issue: 070
|
||||
title: "Backend: notifyAllSellersAboutNewRequest unbounded fan-out — N DB writes + N socket emits per new request"
|
||||
severity: high
|
||||
domain: Marketplace
|
||||
labels: [performance, backend, scalability]
|
||||
status: open
|
||||
created: 2026-05-30
|
||||
source: Full Codebase Audit 2026-05-30
|
||||
---
|
||||
|
||||
# Backend: notifyAllSellersAboutNewRequest unbounded fan-out — N DB writes + N socket emits per new request
|
||||
|
||||
**Severity:** high
|
||||
**Domain:** Marketplace
|
||||
**Labels:** performance, backend, scalability
|
||||
|
||||
## Description
|
||||
|
||||
`PurchaseRequestService.ts:196` loops over every seller and issues one `Notification.insertOne` and one `socket.emit` per seller, wrapped in `setTimeout`. With hundreds of sellers this creates hundreds of sequential DB writes and socket emits, blocking the event loop and risking OOM.
|
||||
|
||||
## Options
|
||||
|
||||
1. Batch with `insertMany` for notifications and a single room/broadcast emit instead of per-seller `setTimeout`.
|
||||
2. Move to a queue/worker that processes seller notifications asynchronously with concurrency limits.
|
||||
3. Fan out via a topic/room subscription rather than per-seller writes.
|
||||
|
||||
## Recommendation
|
||||
|
||||
Use `insertMany` + a single broadcast/room emit, or offload to a queue with bounded concurrency. This is an architectural change.
|
||||
|
||||
## Affected Files
|
||||
|
||||
- `backend/src/services/marketplace/PurchaseRequestService.ts:196`
|
||||
|
||||
## References
|
||||
|
||||
- [Full Codebase Audit 2026-05-30](../09%20-%20Audits/Full%20Codebase%20Audit%20-%202026-05-30.md) — DEC-40
|
||||
Reference in New Issue
Block a user