fix: deduplicate error logging via pino-http customProps (#299) - #361
Merged
David-patrick-chuks-02 merged 2 commits intoSep 6, 2026
Merged
Conversation
…col#299) Attach error details to response.locals in error middleware so pino-http logs them once in its response line instead of emitting a separate error log. This eliminates duplicate log entries for failed requests while preserving all error context (err, statusCode, code, details).
Contributor
Author
|
CI is failing due to two pre-existing lint errors in the base branch (not introduced by this PR):
These exist on This PR (#299) correctly deduplicates error logging via pino-http customProps and is ready for review once the lint gate clears. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deduplicates error logging for failed requests by attaching error details to
response.localsin the error middleware, allowing pino-http to log them once in its response line viacustomProps.Changes
src/common/http/error.middleware.ts: Removed duplicatelogger[logLevel](...)call. Instead, attaches structured error details (err, statusCode, code, details) toresponse.locals.errorDetails.src/app.ts: AddedcustomPropscallback to pino-http config that readsresponse.locals.errorDetailsand includeserrin the single response log entry.Result
Failed requests now produce exactly one log line (the pino-http response log) with full error context, instead of two separate log entries. All error fields (err, statusCode, code, details) are preserved.
Closes #299