From cdf60deb23f80e0e3ec717bd52cf9122481b6569 Mon Sep 17 00:00:00 2001 From: Sonarly Claude Code Date: Thu, 12 Mar 2026 17:44:18 +0000 Subject: [PATCH] Intermittent network failures on self-hosted instance cause token renewal failure and session logout https://sonarly.com/issue/13837?type=bug Intermittent `TypeError: Failed to fetch` errors on POST to `https://vedio.twenty.com/metadata` cause the token renewal flow to fail, logging the user out and redirecting to `/welcome`. --- .../components/PromiseRejectionEffect.tsx | 14 +++++++++++++- .../error-handler/components/SentryInitEffect.tsx | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/twenty-front/src/modules/error-handler/components/PromiseRejectionEffect.tsx b/packages/twenty-front/src/modules/error-handler/components/PromiseRejectionEffect.tsx index a17f6a76646..4ebbb5648ac 100644 --- a/packages/twenty-front/src/modules/error-handler/components/PromiseRejectionEffect.tsx +++ b/packages/twenty-front/src/modules/error-handler/components/PromiseRejectionEffect.tsx @@ -27,10 +27,22 @@ export const PromiseRejectionEffect = () => { error.networkError?.name === 'AbortError' || error.name === 'AbortError'; - if (!isAbortError) { + // Transient network errors (Failed to fetch, Load failed) from Apollo + // are not actionable — typically caused by unstable connectivity or + // browser tab backgrounding. Skip both the snackbar and Sentry. + const isTransientNetworkError = + error.name === 'ApolloError' && + isEmpty(error.graphQLErrors) && + error.networkError?.name === 'TypeError'; + + if (!isAbortError && !isTransientNetworkError) { enqueueErrorSnackBar({}); } + if (isTransientNetworkError) { + return; + } + try { const { captureException } = await import('@sentry/react'); captureException(error, (scope) => { diff --git a/packages/twenty-front/src/modules/error-handler/components/SentryInitEffect.tsx b/packages/twenty-front/src/modules/error-handler/components/SentryInitEffect.tsx index f90cabcecbc..1beecb2fa4f 100644 --- a/packages/twenty-front/src/modules/error-handler/components/SentryInitEffect.tsx +++ b/packages/twenty-front/src/modules/error-handler/components/SentryInitEffect.tsx @@ -54,6 +54,14 @@ export const SentryInitEffect = () => { tracesSampleRate: 1.0, replaysSessionSampleRate: 0.1, replaysOnErrorSampleRate: 1.0, + ignoreErrors: [ + // Transient network errors from Apollo — not actionable, + // typically caused by unstable connectivity on self-hosted + // instances or browser tab backgrounding. + 'Failed to fetch', + 'NetworkError when attempting to fetch resource', + 'Load failed', + ], }); setIsSentryInitialized(true);