Ensure Sentry is triggered before replacing the stack trace

refs: https://github.com/TryGhost/Team/issues/1369

If we prepare the error for users to view before using Sentry, then the error passed to Sentry will have the stack trace removed for production environments.

@tryghost/errors@1.2.5 also made it so that the error is not mutated, but cloned and a new one is returned.
This commit is contained in:
Sam Lord 2022-03-11 10:47:26 +00:00
parent 10e29837e5
commit 51588c6a24
2 changed files with 10 additions and 8 deletions

View File

@ -173,27 +173,27 @@ module.exports.pageNotFound = (req, res, next) => {
};
module.exports.handleJSONResponse = sentry => [
// Make sure the error can be served
module.exports.prepareError,
// Handle the error in Sentry
sentry.errorHandler,
// Make sure the error can be served
module.exports.prepareError,
// Render the error using JSON format
jsonErrorRenderer
];
module.exports.handleJSONResponseV2 = sentry => [
// Make sure the error can be served
module.exports.prepareError,
// Handle the error in Sentry
sentry.errorHandler,
// Make sure the error can be served
module.exports.prepareError,
// Render the error using JSON format
jsonErrorRendererV2
];
module.exports.handleHTMLResponse = sentry => [
// Make sure the error can be served
module.exports.prepareError,
// Handle the error in Sentry
sentry.errorHandler
sentry.errorHandler,
// Make sure the error can be served
module.exports.prepareError
];

View File

@ -26,6 +26,8 @@
},
"dependencies": {
"@tryghost/debug": "^0.1.9",
"@tryghost/tpl": "^0.1.8"
"@tryghost/errors": "1.2.5",
"@tryghost/tpl": "^0.1.8",
"lodash": "4.17.21"
}
}