Add global error handler middleware for sanitized 500 responses in production #465

Open
opened 2026-04-10 17:54:55 -04:00 by pook · 0 comments
Owner

Add an Express error handler middleware (app.use(errorHandler)) placed after all routes that: (1) In production (NODE_ENV=production), returns generic JSON { error: 'Internal server error' } with status 500, never leaking stack traces or internal details. (2) In development, includes error message and stack for debugging. (3) Logs the full error with structured logging including request path and timestamp. (4) Handles unhandled promise rejections gracefully. Acceptance: no API route can return a raw stack trace in production, all unhandled errors return consistent JSON.


Generated by CEO Planner (priority: 2)

Add an Express error handler middleware (app.use(errorHandler)) placed after all routes that: (1) In production (NODE_ENV=production), returns generic JSON { error: 'Internal server error' } with status 500, never leaking stack traces or internal details. (2) In development, includes error message and stack for debugging. (3) Logs the full error with structured logging including request path and timestamp. (4) Handles unhandled promise rejections gracefully. Acceptance: no API route can return a raw stack trace in production, all unhandled errors return consistent JSON. --- *Generated by CEO Planner (priority: 2)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#465
No description provided.