diff --git a/packages/insomnia/src/account/session.ts b/packages/insomnia/src/account/session.ts index 5e068a1f6..15c24bcd8 100644 --- a/packages/insomnia/src/account/session.ts +++ b/packages/insomnia/src/account/session.ts @@ -200,16 +200,19 @@ export function isLoggedIn() { /** Log out and delete session data */ export async function logout() { - try { - await window.main.insomniaFetch({ - method: 'POST', - path: '/auth/logout', - sessionId: getCurrentSessionId(), - }); - } catch (error) { - // Not a huge deal if this fails, but we don't want it to prevent the - // user from signing out. - console.warn('Failed to logout', error); + const sessionId = getCurrentSessionId(); + if (sessionId) { + try { + window.main.insomniaFetch({ + method: 'POST', + path: '/auth/logout', + sessionId, + }); + } catch (error) { + // Not a huge deal if this fails, but we don't want it to prevent the + // user from signing out. + console.warn('Failed to logout', error); + } } _unsetSessionData();