Skip to content

Commit f499328

Browse files
committed
fix: Handle logging of expected timeout and abort errors from instances
1 parent 6ba8947 commit f499328

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

src/features/instance/instanceLayoutRoute.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ async function checkClusterInstanceAuthenticationBeforeLoad({
7979
authStore.flagForFabricConnect(entityId, true);
8080
return;
8181
} catch (err) {
82-
console.error('Fabric Connect not established', err);
82+
// Expected: the instance may be down, restarting, or unauthorized. We fall
83+
// through to the sign-in redirect below. Use debug so RUM doesn't forward it
84+
// to Datadog as an error (RUM only forwards console.error).
85+
console.debug('Fabric Connect not established', err);
8386
}
8487
}
8588

src/integrations/datadog/datadog.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,48 @@ import { useEffect } from 'react';
1111
let initialized = false;
1212
const enabled = !import.meta.env.DEV && !isLocalStudio;
1313

14+
/**
15+
* Reaching an instance can legitimately fail when it's down, restarting, or the
16+
* user lacks Fabric Connect — these are expected states, not Studio bugs, and they
17+
* otherwise flood Error Tracking. Drop connectivity-class errors (timeouts, network
18+
* failures) against instance/cluster operation endpoints so they don't create issues.
19+
*
20+
* Returning false discards the event entirely.
21+
*/
22+
function discardExpectedInstanceErrors(
23+
event: { type: string; error?: { message?: string; source?: string; resource?: { url?: string } } },
24+
) {
25+
if (event.type !== 'error') {
26+
return true;
27+
}
28+
const message = event.error?.message ?? '';
29+
const source = event.error?.source;
30+
31+
// Aborted requests are client-initiated cancellations (navigating away, a
32+
// component unmounting, React Query cancelling an in-flight query) — not failures.
33+
// Safe to drop globally regardless of endpoint.
34+
if (/Request aborted/i.test(message)) {
35+
return false;
36+
}
37+
38+
// Belt-and-suspenders: any stray "Fabric Connect not established" breadcrumb.
39+
if (message.includes('Fabric Connect not established')) {
40+
return false;
41+
}
42+
43+
// Network failures (timeouts, connection refused) against an instance/cluster.
44+
const url = event.error?.resource?.url ?? '';
45+
const isInstanceEndpoint = /\/(HDBInstance|Cluster)\/[^/]+\/operation/.test(url);
46+
const isConnectivityFailure = /timeout of \d+ms exceeded/i.test(message)
47+
|| /Network Error/i.test(message)
48+
|| source === 'network';
49+
if (isInstanceEndpoint && isConnectivityFailure) {
50+
return false;
51+
}
52+
53+
return true;
54+
}
55+
1456
export function useDatadog() {
1557
useEffect(() => {
1658
if (initialized) {
@@ -32,6 +74,8 @@ export function useDatadog() {
3274
trackViewsManually: true,
3375
trackUserInteractions: true,
3476

77+
beforeSend: discardExpectedInstanceErrors,
78+
3579
sessionSampleRate: 100,
3680
sessionReplaySampleRate: 0,
3781
defaultPrivacyLevel: 'mask',

0 commit comments

Comments
 (0)