mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-16 17:46:45 +00:00
fix(core): Dynamically import @sentry/node-native (#18586)
This commit is contained in:
@@ -4,7 +4,6 @@ import { Service } from '@n8n/di';
|
||||
import type { ReportingOptions } from '@n8n/errors';
|
||||
import type { ErrorEvent, EventHint } from '@sentry/core';
|
||||
import type { NodeOptions } from '@sentry/node';
|
||||
import { eventLoopBlockIntegration } from '@sentry/node-native';
|
||||
import { AxiosError } from 'axios';
|
||||
import { ApplicationError, ExecutionCancelledError, BaseError } from 'n8n-workflow';
|
||||
import { createHash } from 'node:crypto';
|
||||
@@ -127,6 +126,8 @@ export class ErrorReporter {
|
||||
'ContextLines',
|
||||
];
|
||||
|
||||
const eventLoopBlockIntegration = await this.getEventLoopBlockIntegration();
|
||||
|
||||
init({
|
||||
dsn,
|
||||
release,
|
||||
@@ -147,7 +148,7 @@ export class ErrorReporter {
|
||||
url: true,
|
||||
},
|
||||
}),
|
||||
eventLoopBlockIntegration(),
|
||||
...eventLoopBlockIntegration,
|
||||
],
|
||||
});
|
||||
|
||||
@@ -253,4 +254,16 @@ export class ErrorReporter {
|
||||
if (extra) event.extra = { ...event.extra, ...extra };
|
||||
if (tags) event.tags = { ...event.tags, ...tags };
|
||||
}
|
||||
|
||||
private async getEventLoopBlockIntegration() {
|
||||
try {
|
||||
const { eventLoopBlockIntegration } = await import('@sentry/node-native');
|
||||
return [eventLoopBlockIntegration()];
|
||||
} catch {
|
||||
this.logger.debug(
|
||||
"Sentry's event loop block integration is disabled, because the native binary for `@sentry/node-native` was not found",
|
||||
);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user