From 1118980bbd72bcd8068279e1e5981b7f28984d5e Mon Sep 17 00:00:00 2001 From: Julian Gruber Date: Mon, 22 Apr 2024 13:29:51 +0200 Subject: [PATCH] fix don't report expected voyager crashes to sentry --- lib/zinnia.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/zinnia.js b/lib/zinnia.js index be9e2dab..5127c4f6 100644 --- a/lib/zinnia.js +++ b/lib/zinnia.js @@ -260,18 +260,22 @@ const catchChildProcessExit = async ({ const moduleName = capitalize(err.moduleName ?? 'Zinnia') const exitReason = err.exitReason ?? 'for unknown reason' const message = `${moduleName} crashed ${exitReason}` - const type = err.moduleName === 'voyager' ? 'info' : 'error' + const isCritical = err.moduleName !== 'voyager' + const type = isCritical ? 'error' : 'info' onActivity({ type, message }) - const moduleErr = new Error(message, { cause: err }) - // Store the full error message including stdout & stder in the top-level `details` property - Object.assign(moduleErr, { details: err.message }) - - // Apply a custom rule to force Sentry to group all issues with the same module & exit code - // See https://docs.sentry.io/platforms/node/usage/sdk-fingerprinting/#basic-example - Sentry.withScope(scope => { - scope.setFingerprint([message]) - maybeReportErrorToSentry(moduleErr) - }) + + if (isCritical) { + const moduleErr = new Error(message, { cause: err }) + // Store the full error message including stdout & stder in the top-level `details` property + Object.assign(moduleErr, { details: err.message }) + + // Apply a custom rule to force Sentry to group all issues with the same module & exit code + // See https://docs.sentry.io/platforms/node/usage/sdk-fingerprinting/#basic-example + Sentry.withScope(scope => { + scope.setFingerprint([message]) + maybeReportErrorToSentry(moduleErr) + }) + } throw err } } finally {