-
Notifications
You must be signed in to change notification settings - Fork 359
Open
Description
When a user attempts to log in but encounters a network error (e.g., net::ERR_NETWORK_CHANGED or a DNS failure), the fetch call in EmbeddedChatApi.login throws an error.
The catch block in packages/api/src/EmbeddedChatApi.ts currently logs the error but implicitly returns undefined:
// packages/api/src/EmbeddedChatApi.ts
if (error instanceof ApiError && error.response?.status === 401) {
const authErrorRes = await error.response.json();
return { error: authErrorRes?.error };
}
console.error(error); // returns undefined implicitlySubsequently, the react hook useRCAuth.js attempts to read res.error, leading to an uncaught TypeError, completely crashing the login flow and preventing any toast error message from being displayed to the user:
// packages/react/src/hooks/useRCAuth.js
const res = await RCInstance.login(userOrEmail, password, code);
if (res.error === 'Unauthorized' || res.error === 403) { // TypeError: Cannot read properties of undefined (reading 'error')Steps To Reproduce
- Open the EmbeddedChat application
- Go to the offline state or throttle your network connection to drop it mid-request.
- Attempt to submit the login form.
- Observe the unhandled promise rejection and UI crash instead of a graceful toast message.
Expected Behavior
The login flow should robustly handle network errors returned by RCInstance.login(), exiting gracefully and optionally displaying a user-friendly error toast.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels