Skip to content

Commit 1b1fac0

Browse files
committed
Changed require() on sentry to boot faster
ref https://linear.app/ghost/issue/BER-3132 - The `require('@tryghost/errors')` adds 50-100ms on boot time, this is due to the package's own initialization and `require()`. Since it's not needed at boot, it can be moved inside the `beforeSend` function.
1 parent 7262fa0 commit 1b1fac0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ghost/core/core/shared/sentry.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const config = require('./config');
22
const SentryKnexTracingIntegration = require('./SentryKnexTracingIntegration');
33
const sentryConfig = config.get('sentry');
4-
const errors = require('@tryghost/errors');
4+
let _errors;
55

66
/**
77
* @param {import('@sentry/node').Event} event
@@ -10,6 +10,7 @@ const errors = require('@tryghost/errors');
1010
*/
1111
const beforeSend = function (event, hint) {
1212
try {
13+
const errors = _errors || (_errors = require('@tryghost/errors'));
1314
const exception = hint.originalException;
1415
const code = exception?.code ?? null;
1516
const context = exception?.context ?? null;

0 commit comments

Comments
 (0)