mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
perf: Lazy-load queue-mode and analytics dependencies (#5061)
* refactor: lazy load ioredis and bull * upgrade bull and hiredis * refactor: lazy load posthog, rudderstack, and sentry * upgrade Sentry sdk
This commit is contained in:
committed by
GitHub
parent
7e3f3c5097
commit
b828cb31d6
@@ -1,12 +1,10 @@
|
||||
import * as Sentry from '@sentry/node';
|
||||
import { RewriteFrames } from '@sentry/integrations';
|
||||
import type { Application } from 'express';
|
||||
import config from '@/config';
|
||||
import { ErrorReporterProxy } from 'n8n-workflow';
|
||||
|
||||
let initialized = false;
|
||||
|
||||
export const initErrorHandling = () => {
|
||||
export const initErrorHandling = async () => {
|
||||
if (initialized) return;
|
||||
|
||||
if (!config.getEnv('diagnostics.enabled')) {
|
||||
@@ -20,7 +18,11 @@ export const initErrorHandling = () => {
|
||||
const dsn = config.getEnv('diagnostics.config.sentry.dsn');
|
||||
const { N8N_VERSION: release, ENVIRONMENT: environment } = process.env;
|
||||
|
||||
Sentry.init({
|
||||
const { init, captureException } = await import('@sentry/node');
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
const { RewriteFrames } = await import('@sentry/integrations');
|
||||
|
||||
init({
|
||||
dsn,
|
||||
release,
|
||||
environment,
|
||||
@@ -37,14 +39,16 @@ export const initErrorHandling = () => {
|
||||
});
|
||||
|
||||
ErrorReporterProxy.init({
|
||||
report: (error, options) => Sentry.captureException(error, options),
|
||||
report: (error, options) => captureException(error, options),
|
||||
});
|
||||
|
||||
initialized = true;
|
||||
};
|
||||
|
||||
export const setupErrorMiddleware = (app: Application) => {
|
||||
const { requestHandler, errorHandler } = Sentry.Handlers;
|
||||
export const setupErrorMiddleware = async (app: Application) => {
|
||||
const {
|
||||
Handlers: { requestHandler, errorHandler },
|
||||
} = await import('@sentry/node');
|
||||
app.use(requestHandler());
|
||||
app.use(errorHandler());
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user