diff --git a/packages/cli/src/ErrorReporting.ts b/packages/cli/src/ErrorReporting.ts index e9059e71ba..b12a19f95e 100644 --- a/packages/cli/src/ErrorReporting.ts +++ b/packages/cli/src/ErrorReporting.ts @@ -7,6 +7,10 @@ let initialized = false; export const initErrorHandling = async () => { if (initialized) return; + process.on('uncaughtException', (error) => { + ErrorReporterProxy.error(error); + }); + const dsn = config.getEnv('diagnostics.config.sentry.dsn'); if (!config.getEnv('diagnostics.enabled') || !dsn) { initialized = true; @@ -44,10 +48,6 @@ export const initErrorHandling = async () => { return event; }); - process.on('uncaughtException', (error) => { - ErrorReporterProxy.error(error); - }); - ErrorReporterProxy.init({ report: (error, options) => captureException(error, options), }); diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index b68c5a06d6..e053949c92 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -689,6 +689,8 @@ export async function proxyRequestToAxios( // https://github.com/axios/axios/blob/master/lib/core/enhanceError.js // Note: `code` is ignored as it's an expected part of the errorData. if (error.isAxiosError) { + error.config = error.request = undefined; + error.options = pick(config ?? {}, ['url', 'method', 'data', 'headers']); if (response) { Logger.debug('Request proxied to Axios failed', { status: response.status }); let responseData = response.data; @@ -712,23 +714,14 @@ export async function proxyRequestToAxios( } } - const message = `${response.status as number} - ${JSON.stringify(responseData)}`; + error.message = `${response.status as number} - ${JSON.stringify(responseData)}`; throw Object.assign(error, { - message, statusCode: response.status, - options: pick(config ?? {}, ['url', 'method', 'data', 'headers']), error: responseData, - config: undefined, - request: undefined, response: pick(response, ['headers', 'status', 'statusText']), }); - } else { - if (error instanceof Error && error.message.includes('SSL routines')) - throw new NodeSSLError(error); - - throw Object.assign(error, { - options: pick(config ?? {}, ['url', 'method', 'data', 'headers']), - }); + } else if (error instanceof Error && error.message.includes('SSL routines')) { + throw new NodeSSLError(error); } }