mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +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 { ReportingOptions } from '@n8n/errors';
|
||||||
import type { ErrorEvent, EventHint } from '@sentry/core';
|
import type { ErrorEvent, EventHint } from '@sentry/core';
|
||||||
import type { NodeOptions } from '@sentry/node';
|
import type { NodeOptions } from '@sentry/node';
|
||||||
import { eventLoopBlockIntegration } from '@sentry/node-native';
|
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
import { ApplicationError, ExecutionCancelledError, BaseError } from 'n8n-workflow';
|
import { ApplicationError, ExecutionCancelledError, BaseError } from 'n8n-workflow';
|
||||||
import { createHash } from 'node:crypto';
|
import { createHash } from 'node:crypto';
|
||||||
@@ -127,6 +126,8 @@ export class ErrorReporter {
|
|||||||
'ContextLines',
|
'ContextLines',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const eventLoopBlockIntegration = await this.getEventLoopBlockIntegration();
|
||||||
|
|
||||||
init({
|
init({
|
||||||
dsn,
|
dsn,
|
||||||
release,
|
release,
|
||||||
@@ -147,7 +148,7 @@ export class ErrorReporter {
|
|||||||
url: true,
|
url: true,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
eventLoopBlockIntegration(),
|
...eventLoopBlockIntegration,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -253,4 +254,16 @@ export class ErrorReporter {
|
|||||||
if (extra) event.extra = { ...event.extra, ...extra };
|
if (extra) event.extra = { ...event.extra, ...extra };
|
||||||
if (tags) event.tags = { ...event.tags, ...tags };
|
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