Skip to content

Commit aab7e9a

Browse files
committed
Catch @hapi/podium errors
1 parent 69845cc commit aab7e9a

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

packages/kbn-legacy-logging/src/legacy_logging_server.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,18 @@ export class LegacyLoggingServer {
117117
public log({ level, context, message, error, timestamp, meta = {} }: LogRecord) {
118118
const { tags = [], ...metadata } = meta;
119119

120-
this.events.emit('log', {
121-
data: getDataToLog(error, metadata, message),
122-
tags: [getLegacyLogLevel(level), ...context.split('.'), ...tags],
123-
timestamp: timestamp.getTime(),
124-
});
120+
this.events
121+
.emit('log', {
122+
data: getDataToLog(error, metadata, message),
123+
tags: [getLegacyLogLevel(level), ...context.split('.'), ...tags],
124+
timestamp: timestamp.getTime(),
125+
})
126+
// @ts-expect-error @hapi/podium emit is actually an async function
127+
.catch((err) => {
128+
// eslint-disable-next-line no-console
129+
console.error('An unexpected error occurred while writing to the log:', err.stack);
130+
process.exit(1);
131+
});
125132
}
126133

127134
public stop() {

0 commit comments

Comments
 (0)