diff --git a/libs/shared/data-access/cookie/src/service.ts b/libs/shared/data-access/cookie/src/service.ts index 30ac0cdb..f2a358ce 100644 --- a/libs/shared/data-access/cookie/src/service.ts +++ b/libs/shared/data-access/cookie/src/service.ts @@ -1,3 +1,4 @@ +import * as Sentry from '@sentry/react-native'; import NitroCookies from 'react-native-nitro-cookies'; import { getApiUrl } from '@open-webui-react-native/shared/utils/config'; @@ -5,13 +6,24 @@ class CookieService { public async setToken(token: string): Promise { const apiUrl = `${getApiUrl()}/api/`; - await NitroCookies.set(apiUrl, { - name: 'token', - value: token, - path: '/', - secure: true, - httpOnly: false, - }); + try { + await NitroCookies.set(apiUrl, { + name: 'token', + value: token, + path: '/', + secure: true, + httpOnly: false, + }); + } catch (error) { + // NOTE: callers (authState$.signIn, appState$.init) fire this without awaiting it — the real + // auth token already lives in storage and the Authorization header by this point, so this + // cookie is only a best-effort mirror (used by webviews). Report but don't let it surface as + // an unhandled promise rejection. + Sentry.withScope((scope) => { + scope.setTag('cookie.operation', 'setToken'); + Sentry.captureException(error); + }); + } } public async clearAll(): Promise {