From 310ecd37c4433f4894952231f38bcb3352ef5d66 Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Mon, 1 Jun 2020 19:01:51 +0100 Subject: [PATCH] Fixed handling non-Ghost errors in Sentry no issue - in the near future, non-Ghost Ignition type errors will be coming into Sentry - because they don't have a statusCode, they'll be rejected - we want to detect if they're non-Ghost and still deal with them --- core/shared/sentry.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/shared/sentry.js b/core/shared/sentry.js index fe89ed63cf..2b63467cdd 100644 --- a/core/shared/sentry.js +++ b/core/shared/sentry.js @@ -1,5 +1,6 @@ const config = require('./config'); const sentryConfig = config.get('sentry'); +const errors = require('@tryghost/errors'); const expressNoop = function (req, res, next) { next(); @@ -19,6 +20,12 @@ if (sentryConfig && !sentryConfig.disabled) { requestHandler: Sentry.Handlers.requestHandler(), errorHandler: Sentry.Handlers.errorHandler({ shouldHandleError(error) { + // Sometimes non-Ghost issues will come into here but they won't + // have a statusCode so we should always handle them + if (!errors.utils.isIgnitionError(error)) { + return true; + } + // Only handle 500 errors for now // This is because the only other 5XX error should be 503, which are deliberate maintenance/boot errors return (error.statusCode === 500);