mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-25 11:31:38 -08:00
fix(core): Fix sentry de-duplication by migrating from event-processors to beforeSend (no-changelog) (#10947)
This commit is contained in:
parent
dcc1c72fc4
commit
a81256aff5
|
@ -29,7 +29,7 @@ export const initErrorHandling = async () => {
|
||||||
DEPLOYMENT_NAME: serverName,
|
DEPLOYMENT_NAME: serverName,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
||||||
const { init, captureException, addEventProcessor } = await import('@sentry/node');
|
const { init, captureException } = await import('@sentry/node');
|
||||||
|
|
||||||
const { RewriteFrames } = await import('@sentry/integrations');
|
const { RewriteFrames } = await import('@sentry/integrations');
|
||||||
const { Integrations } = await import('@sentry/node');
|
const { Integrations } = await import('@sentry/node');
|
||||||
|
@ -41,6 +41,8 @@ export const initErrorHandling = async () => {
|
||||||
'OnUnhandledRejection',
|
'OnUnhandledRejection',
|
||||||
'ContextLines',
|
'ContextLines',
|
||||||
];
|
];
|
||||||
|
const seenErrors = new Set<string>();
|
||||||
|
|
||||||
init({
|
init({
|
||||||
dsn,
|
dsn,
|
||||||
release,
|
release,
|
||||||
|
@ -62,34 +64,32 @@ export const initErrorHandling = async () => {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
beforeSend(event, { originalException }) {
|
||||||
|
if (!originalException) return null;
|
||||||
|
|
||||||
const seenErrors = new Set<string>();
|
if (
|
||||||
addEventProcessor((event, { originalException }) => {
|
originalException instanceof QueryFailedError &&
|
||||||
if (!originalException) return null;
|
['SQLITE_FULL', 'SQLITE_IOERR'].some((errMsg) => originalException.message.includes(errMsg))
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (originalException instanceof ApplicationError) {
|
||||||
originalException instanceof QueryFailedError &&
|
const { level, extra, tags } = originalException;
|
||||||
['SQLITE_FULL', 'SQLITE_IOERR'].some((errMsg) => originalException.message.includes(errMsg))
|
if (level === 'warning') return null;
|
||||||
) {
|
event.level = level;
|
||||||
return null;
|
if (extra) event.extra = { ...event.extra, ...extra };
|
||||||
}
|
if (tags) event.tags = { ...event.tags, ...tags };
|
||||||
|
}
|
||||||
|
|
||||||
if (originalException instanceof ApplicationError) {
|
if (originalException instanceof Error && originalException.stack) {
|
||||||
const { level, extra, tags } = originalException;
|
const eventHash = createHash('sha1').update(originalException.stack).digest('base64');
|
||||||
if (level === 'warning') return null;
|
if (seenErrors.has(eventHash)) return null;
|
||||||
event.level = level;
|
seenErrors.add(eventHash);
|
||||||
if (extra) event.extra = { ...event.extra, ...extra };
|
}
|
||||||
if (tags) event.tags = { ...event.tags, ...tags };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (originalException instanceof Error && originalException.stack) {
|
return event;
|
||||||
const eventHash = createHash('sha1').update(originalException.stack).digest('base64');
|
},
|
||||||
if (seenErrors.has(eventHash)) return null;
|
|
||||||
seenErrors.add(eventHash);
|
|
||||||
}
|
|
||||||
|
|
||||||
return event;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ErrorReporterProxy.init({
|
ErrorReporterProxy.init({
|
||||||
|
|
Loading…
Reference in a new issue