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

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-08-14 17:26:40 +02:00 committed by GitHub
parent 4e4a3cf7ab
commit 96ff1f847d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 16 deletions

View file

@ -7,6 +7,10 @@ let initialized = false;
export const initErrorHandling = async () => { export const initErrorHandling = async () => {
if (initialized) return; if (initialized) return;
process.on('uncaughtException', (error) => {
ErrorReporterProxy.error(error);
});
const dsn = config.getEnv('diagnostics.config.sentry.dsn'); const dsn = config.getEnv('diagnostics.config.sentry.dsn');
if (!config.getEnv('diagnostics.enabled') || !dsn) { if (!config.getEnv('diagnostics.enabled') || !dsn) {
initialized = true; initialized = true;
@ -44,10 +48,6 @@ export const initErrorHandling = async () => {
return event; return event;
}); });
process.on('uncaughtException', (error) => {
ErrorReporterProxy.error(error);
});
ErrorReporterProxy.init({ ErrorReporterProxy.init({
report: (error, options) => captureException(error, options), report: (error, options) => captureException(error, options),
}); });

View file

@ -689,6 +689,8 @@ export async function proxyRequestToAxios(
// https://github.com/axios/axios/blob/master/lib/core/enhanceError.js // https://github.com/axios/axios/blob/master/lib/core/enhanceError.js
// Note: `code` is ignored as it's an expected part of the errorData. // Note: `code` is ignored as it's an expected part of the errorData.
if (error.isAxiosError) { if (error.isAxiosError) {
error.config = error.request = undefined;
error.options = pick(config ?? {}, ['url', 'method', 'data', 'headers']);
if (response) { if (response) {
Logger.debug('Request proxied to Axios failed', { status: response.status }); Logger.debug('Request proxied to Axios failed', { status: response.status });
let responseData = response.data; 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, { throw Object.assign(error, {
message,
statusCode: response.status, statusCode: response.status,
options: pick(config ?? {}, ['url', 'method', 'data', 'headers']),
error: responseData, error: responseData,
config: undefined,
request: undefined,
response: pick(response, ['headers', 'status', 'statusText']), response: pick(response, ['headers', 'status', 'statusText']),
}); });
} else { } else if (error instanceof Error && error.message.includes('SSL routines')) {
if (error instanceof Error && error.message.includes('SSL routines'))
throw new NodeSSLError(error); throw new NodeSSLError(error);
throw Object.assign(error, {
options: pick(config ?? {}, ['url', 'method', 'data', 'headers']),
});
} }
} }