From b31a44aa76dfc9d5694c42103a5dfda9c9a3412e Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Fri, 26 Mar 2021 12:48:46 -0400 Subject: [PATCH] Do not continue writing after stream has closed --- ts/logging/main_process_logging.ts | 8 ++++++++ ts/logging/set_up_renderer_logging.ts | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/ts/logging/main_process_logging.ts b/ts/logging/main_process_logging.ts index 84c6d10e8e20..4614a2c2d0d4 100644 --- a/ts/logging/main_process_logging.ts +++ b/ts/logging/main_process_logging.ts @@ -69,6 +69,14 @@ export async function initialize(): Promise { rotate: 3, }); + stream.on('close', () => { + globalLogger = undefined; + }); + + stream.on('error', () => { + globalLogger = undefined; + }); + const streams: pinoms.Streams = []; streams.push({ stream }); diff --git a/ts/logging/set_up_renderer_logging.ts b/ts/logging/set_up_renderer_logging.ts index c4d83508bca1..4a69ecd5afa2 100644 --- a/ts/logging/set_up_renderer_logging.ts +++ b/ts/logging/set_up_renderer_logging.ts @@ -112,6 +112,14 @@ export function initialize(): void { rotate: 3, }); + stream.on('close', () => { + globalLogger = undefined; + }); + + stream.on('error', () => { + globalLogger = undefined; + }); + globalLogger = pino( { timestamp: pino.stdTimeFunctions.isoTime,