n8n
Version:
n8n Workflow Automation Tool
110 lines • 4.41 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.initErrorHandling = void 0;
const crypto_1 = require("crypto");
const config_1 = __importDefault(require("./config"));
const n8n_workflow_1 = require("n8n-workflow");
const typeorm_1 = require("@n8n/typeorm");
let initialized = false;
const initErrorHandling = async () => {
if (initialized)
return;
process.on('uncaughtException', (error) => {
n8n_workflow_1.ErrorReporterProxy.error(error);
});
const dsn = config_1.default.getEnv('diagnostics.config.sentry.dsn');
if (!dsn) {
initialized = true;
return;
}
Error.stackTraceLimit = 50;
const { N8N_VERSION: release, ENVIRONMENT: environment, DEPLOYMENT_NAME: serverName, } = process.env;
const { init, captureException, addEventProcessor } = await Promise.resolve().then(() => __importStar(require('@sentry/node')));
const { RewriteFrames } = await Promise.resolve().then(() => __importStar(require('@sentry/integrations')));
const { Integrations } = await Promise.resolve().then(() => __importStar(require('@sentry/node')));
const enabledIntegrations = [
'InboundFilters',
'FunctionToString',
'LinkedErrors',
'OnUnhandledRejection',
'ContextLines',
];
init({
dsn,
release,
environment,
enableTracing: false,
serverName,
beforeBreadcrumb: () => null,
integrations: (integrations) => [
...integrations.filter(({ name }) => enabledIntegrations.includes(name)),
new RewriteFrames({ root: process.cwd() }),
new Integrations.RequestData({
include: {
cookies: false,
data: false,
headers: false,
query_string: false,
url: true,
user: false,
},
}),
],
});
const seenErrors = new Set();
addEventProcessor((event, { originalException }) => {
if (!originalException)
return null;
if (originalException instanceof typeorm_1.QueryFailedError &&
['SQLITE_FULL', 'SQLITE_IOERR'].some((errMsg) => originalException.message.includes(errMsg))) {
return null;
}
if (originalException instanceof n8n_workflow_1.ApplicationError) {
const { level, extra, tags } = originalException;
if (level === 'warning')
return null;
event.level = level;
if (extra)
event.extra = { ...event.extra, ...extra };
if (tags)
event.tags = { ...event.tags, ...tags };
}
const eventHash = (0, crypto_1.createHash)('sha1').update(JSON.stringify(originalException)).digest('base64');
if (seenErrors.has(eventHash))
return null;
seenErrors.add(eventHash);
return event;
});
n8n_workflow_1.ErrorReporterProxy.init({
report: (error, options) => captureException(error, options),
});
initialized = true;
};
exports.initErrorHandling = initErrorHandling;
//# sourceMappingURL=ErrorReporting.js.map
;