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
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2022-12-16 13:23:24 +01:00 committed by GitHub
parent 626879b3a2
commit 6127c958f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View file

@ -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),
});

View file

@ -187,15 +187,12 @@ export class Telemetry {
properties: updatedProperties,
};
if (withPostHog && this.postHog) {
return Promise.all([
this.postHog.capture({
if (withPostHog) {
this.postHog?.capture({
distinctId: payload.userId,
sendFeatureFlags: true,
...payload,
}),
this.rudderStack.track(payload),
]).then(() => resolve());
});
}
return this.rudderStack.track(payload, resolve);