♦fix: handle network errors in validateAndSignUpUser (#4285) - #4294
Open
PS01K wants to merge 1 commit into
Open
Conversation
- Guard against undefined error.response in validateAndSignUpUser by safely extracting message via optional chaining - Update authError type definition to accept string payloads - Guard against similar missing error.response crashes in validateAndLoginUser, logoutUser, unlinkService, and setUserCookieConsent - Return promise from logoutUser thunk - Add unit tests covering signup, login, and logout network error handling
|
🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue:
Fixes #4285
When submitting the signup form during a network error, request timeout, or server disconnection, Axios produces an error object where
error.responseisundefined.Previously,
validateAndSignUpUser()attempted to accessresponse.data.errordirectly inside its.catch()handler. This caused a synchronousTypeError: Cannot read properties of undefined (reading 'data'), preventingresolve({ error })from executing. Consequently, the promise returned to React Final Form remained pending indefinitely, freezing the signup form in a permanentsubmittingstate with disabled submit controls and no user feedback.Changes:
client/modules/User/actions.ts:validateAndSignUpUserusing optional chaining (error.response?.data?.error || error.response?.data?.message || error.message || 'Unknown error.') soauthErroris dispatched andresolve({ error })is always reached.authError(error: Error | string)type definition to permit string error payloads.error.responsecrashes invalidateAndLoginUser,logoutUser,unlinkService, andsetUserCookieConsent.logoutUserthunk.client/modules/User/actions.unit.test.ts:I have verified that this pull request:
npm run lint)npm run test)npm run typecheck)developbranch.Fixes #4285