Compare commits

...
Author SHA1 Message Date
Sonarly Claude CodeandClaude Opus 4.6 4d30170daa Fix ApolloError NetworkError after failed token renewal on /welcome page
When token renewal fails (e.g., no refresh token available), the operation
was still being forwarded via fromPromise().flatMap(() => forward(operation)),
causing retried requests without valid tokens. These requests would fail with
NetworkError, get retried by RetryLink, and eventually bubble up as unhandled
ApolloErrors to Sentry.

Now we check if a valid token pair exists after the renewal attempt before
forwarding the operation. If no tokens are available (renewal failed), we
return an empty Observable to silently drop the operation since the user has
already been redirected to the sign-in page.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 00:22:49 +00:00
@@ -4,7 +4,7 @@ import {
ApolloLink,
type FetchResult,
fromPromise,
type Observable,
Observable,
type Operation,
type ServerError,
type ServerParseError,
@@ -181,7 +181,16 @@ export class ApolloFactory<TCacheShape> implements ApolloManager<TCacheShape> {
});
}
return fromPromise(renewalPromise).flatMap(() => forward(operation));
return fromPromise(renewalPromise).flatMap(() => {
// If token pair is not available after renewal attempt,
// don't retry the operation — renewal has failed and the
// user has already been redirected to the sign-in page.
if (isUndefinedOrNull(getTokenPair())) {
return new Observable<FetchResult>(() => {});
}
return forward(operation);
});
};
const sendToSentry = ({