Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Commit

Permalink
fix(config): stop crash when logs written async (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Aug 16, 2023
1 parent a23b286 commit 2332c58
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,24 @@ async function getConfig() {
level: env.LOG_LEVEL || "info",
redact: ["req.headers.authorization"],
serializers: {
/**
* @param {import("http").IncomingMessage} req - Request message.
* @returns {import("pino").SerializedRequest} Serialized request.
*/
/* istanbul ignore next: pino functions not explicitly tested */
req(req) {
return stdSerializers.req(req);
},
/**
* @param {import("http").ServerResponse<import("http").IncomingMessage>} res - Response message.
* @returns {import("pino").SerializedResponse} Serialized response.
*/
/* istanbul ignore next: pino functions not explicitly tested */
res(res) {
/**
* Required for the statusCode to be logged:
* https://github.com/pinojs/pino-std-serializers/blob/901dae44c2b71497cdb0f76f6b5af62588107e3e/lib/res.js#L37
*/
res.headersSent = true;
return stdSerializers.res(res);
return {
...stdSerializers.res(res),
statusCode: res.statusCode,
};
},
},
timestamp: () => stdTimeFunctions.isoTime(),
Expand Down

0 comments on commit 2332c58

Please sign in to comment.