Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0
Why this matters
error.middleware.ts:9-56 unconditionally calls res.status(...).json(...) in every branch with no if (res.headersSent) return next(err) check. If an error surfaces after headers were already written (e.g. the SSE subscribe path writes res.writeHead(200) then can throw), this throws a secondary error and can crash the request instead of delegating to Express's default finalizer.
Acceptance criteria
Files to touch
backend/src/middleware/error.middleware.ts
Out of scope
- Reworking error response shapes
Why this matters
error.middleware.ts:9-56 unconditionally calls res.status(...).json(...) in every branch with no if (res.headersSent) return next(err) check. If an error surfaces after headers were already written (e.g. the SSE subscribe path writes res.writeHead(200) then can throw), this throws a secondary error and can crash the request instead of delegating to Express's default finalizer.
Acceptance criteria
Files to touch
backend/src/middleware/error.middleware.tsOut of scope