Problem
app/config/logger.js tries to opt into pretty-printed logs when LOG_PRETTY=1, with a guard against pino-pretty not being installed:
let transport;
if (process.env.LOG_PRETTY === '1') {
try {
transport = {
target: 'pino-pretty',
options: { colorize: true, translateTime: 'SYS:standard' },
};
} catch (_) {
// pino-pretty not installed — fall through to JSON output.
}
}
The try/catch is a no-op. Constructing an object literal doesn't throw. pino-pretty is lazy-resolved by pino itself the first time the logger emits — usually during DB init seconds into startup. A deployment that sets LOG_PRETTY=1 without pino-pretty on disk (it's not in dependencies) crashes there with a confusing internal pino error. The "fall through to JSON output" the comment promised never executes.
Proposed fix
Add an explicit require.resolve('pino-pretty') inside the try block. require.resolve synchronously throws MODULE_NOT_FOUND when the module is missing, so the catch fires cleanly and transport stays undefined — pino then falls through to default JSON output, which is what an operator who asked for pretty logs but hasn't installed the optional dep should see.
Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/
Problem
app/config/logger.jstries to opt into pretty-printed logs whenLOG_PRETTY=1, with a guard againstpino-prettynot being installed:The
try/catchis a no-op. Constructing an object literal doesn't throw.pino-prettyis lazy-resolved bypinoitself the first time the logger emits — usually during DB init seconds into startup. A deployment that setsLOG_PRETTY=1withoutpino-prettyon disk (it's not independencies) crashes there with a confusing internal pino error. The "fall through to JSON output" the comment promised never executes.Proposed fix
Add an explicit
require.resolve('pino-pretty')inside the try block.require.resolvesynchronously throwsMODULE_NOT_FOUNDwhen the module is missing, so the catch fires cleanly andtransportstays undefined — pino then falls through to default JSON output, which is what an operator who asked for pretty logs but hasn't installed the optional dep should see.Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/