diff --git a/ui/src/config/transport.ts b/ui/src/config/transport.ts index c02434d96..3cb56d5e6 100644 --- a/ui/src/config/transport.ts +++ b/ui/src/config/transport.ts @@ -1,4 +1,4 @@ -import { ConnectError, Interceptor } from '@connectrpc/connect'; +import { Code, ConnectError, Interceptor } from '@connectrpc/connect'; import { createConnectTransport } from '@connectrpc/connect-web'; import { notification } from 'antd'; @@ -55,6 +55,12 @@ export const newErrorHandler = (handler: (err: ConnectError) => void): Intercept handler(err); + // in rare cases, token is invalid but UI could not detect it beforehand + // CodeUnauthenticated <- to ease the global code search + if (err instanceof ConnectError && err?.code === Code.Unauthenticated) { + logout(); + } + throw err; }); };