Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(HTTP Request Node): Improve error handling for TCP socket errors when Continue On Fail is enabled #6925

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/cli/src/ErrorReporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
});
Expand Down
17 changes: 5 additions & 12 deletions packages/core/src/NodeExecuteFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand Down
Loading