From 6127c958f5ed786ee93f8fedb3344d6792158723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Fri, 16 Dec 2022 13:23:24 +0100 Subject: [PATCH] fix: Do not crash the server when Telemetry is blocked via DNS (#4947) * do not crash the process on unhandled axios errors * postHog.capture does not return a promise --- packages/cli/src/ErrorReporting.ts | 6 ++++++ packages/cli/src/telemetry/index.ts | 15 ++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/ErrorReporting.ts b/packages/cli/src/ErrorReporting.ts index a1590cf29..66ff5f0ba 100644 --- a/packages/cli/src/ErrorReporting.ts +++ b/packages/cli/src/ErrorReporting.ts @@ -25,11 +25,17 @@ export const initErrorHandling = () => { release, environment, integrations: (integrations) => { + integrations = integrations.filter(({ name }) => name !== 'OnUncaughtException'); integrations.push(new RewriteFrames({ root: process.cwd() })); return integrations; }, }); + process.on('uncaughtException', (error) => { + ErrorReporterProxy.error(error); + if (error.constructor?.name !== 'AxiosError') throw error; + }); + ErrorReporterProxy.init({ report: (error, options) => Sentry.captureException(error, options), }); diff --git a/packages/cli/src/telemetry/index.ts b/packages/cli/src/telemetry/index.ts index f37261b3b..cb81e59ed 100644 --- a/packages/cli/src/telemetry/index.ts +++ b/packages/cli/src/telemetry/index.ts @@ -187,15 +187,12 @@ export class Telemetry { properties: updatedProperties, }; - if (withPostHog && this.postHog) { - return Promise.all([ - this.postHog.capture({ - distinctId: payload.userId, - sendFeatureFlags: true, - ...payload, - }), - this.rudderStack.track(payload), - ]).then(() => resolve()); + if (withPostHog) { + this.postHog?.capture({ + distinctId: payload.userId, + sendFeatureFlags: true, + ...payload, + }); } return this.rudderStack.track(payload, resolve);