From 756508f54e89b0823272efc3fe1b0a8807530fc6 Mon Sep 17 00:00:00 2001 From: Aryan Patil Date: Sat, 17 Oct 2026 23:44:10 +0530 Subject: [PATCH 1/2] fix: Prevent crash when login API returns undefined --- packages/react/src/hooks/useRCAuth.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/react/src/hooks/useRCAuth.js b/packages/react/src/hooks/useRCAuth.js index 385f300a0..d63d2a148 100644 --- a/packages/react/src/hooks/useRCAuth.js +++ b/packages/react/src/hooks/useRCAuth.js @@ -25,6 +25,14 @@ export const useRCAuth = () => { const handleLogin = async (userOrEmail, password, code) => { try { const res = await RCInstance.login(userOrEmail, password, code); + if (!res) { + dispatchToastMessage({ + type: 'error', + message: + 'Unable to connect to server. Please check your connection and try again.', + }); + return; + } if (res.error === 'Unauthorized' || res.error === 403) { dispatchToastMessage({ type: 'error', From f75c9a7a7e6f71a93440414fdba96166eb56a0cc Mon Sep 17 00:00:00 2001 From: Aryan Patil Date: Fri, 23 Oct 2026 18:52:33 +0530 Subject: [PATCH 2/2] fix: Rethrow non-401 errors from EmbeddedChatApi.login --- packages/api/src/EmbeddedChatApi.ts | 1 + packages/react/src/hooks/useRCAuth.js | 8 -------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/api/src/EmbeddedChatApi.ts b/packages/api/src/EmbeddedChatApi.ts index 6f2408414..d84d0d624 100644 --- a/packages/api/src/EmbeddedChatApi.ts +++ b/packages/api/src/EmbeddedChatApi.ts @@ -192,6 +192,7 @@ export default class EmbeddedChatApi { return { error: authErrorRes?.error }; } console.error(error instanceof Error ? error.message : error); + throw error; } } diff --git a/packages/react/src/hooks/useRCAuth.js b/packages/react/src/hooks/useRCAuth.js index d63d2a148..385f300a0 100644 --- a/packages/react/src/hooks/useRCAuth.js +++ b/packages/react/src/hooks/useRCAuth.js @@ -25,14 +25,6 @@ export const useRCAuth = () => { const handleLogin = async (userOrEmail, password, code) => { try { const res = await RCInstance.login(userOrEmail, password, code); - if (!res) { - dispatchToastMessage({ - type: 'error', - message: - 'Unable to connect to server. Please check your connection and try again.', - }); - return; - } if (res.error === 'Unauthorized' || res.error === 403) { dispatchToastMessage({ type: 'error',