-
-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Describe the bug
The globalErrorHandler in express-error-toolkit is built to simplify error handling and remove repetitive middleware boilerplate. However, when the server runs on port 3000 — where a frontend app (like Next.js or React) was previously running — the toolkit displays an unnecessary favicon error message.
Example output:
favicon error
Even the best code breaks sometimes! Let's debug...
🔴 Error Status: 404
🔴 Error Message: Cannot GET /favicon.ico
🟢 Stack Trace (Preview):
c: Cannot GET /favicon.ico
at L (C:\Projects\ai-devScribe\server\node_modules.pnpm\[email protected]\node_modules\express-error-toolkit\dist\index.cjs:1:2392)
at Layer.handleRequest (C:\Projects\ai-devScribe\server\node_modules.pnpm\[email protected]\node_modules\router\lib\layer.js:152:17)
This is not an actual error, but it gets caught and displayed by the global error handler even though the favicon request is harmless.
To Reproduce
- Run a frontend app (e.g., Next.js) on port 3000.
- Stop the frontend app.
- Start an Express server using
express-error-toolkiton the same port (3000). - Observe the console/log output — a “favicon error” message appears.
Expected behavior
The globalErrorHandler should ignore favicon.ico 404 errors or handle them silently, as they are not true application errors.
Proposed fix
Add a condition in the global error handler to bypass or filter out errors related to /favicon.ico requests. This will keep the error logs clean and relevant.
Additional context
This occurs when a frontend app was previously served on the same port. The browser still attempts to request /favicon.ico, triggering a false 404 error handled by the toolkit.