-
Notifications
You must be signed in to change notification settings - Fork 78
fix: prevent search source pagination on non-retryable response errors #1638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: prevent search source pagination on non-retryable response errors #1638
Conversation
|
Size Change: +265 B (+0.07%) Total Size: 354 kB
|
src/search/ChannelSearchSource.ts
Outdated
| protected isFatalError = (error: Error) => { | ||
| // unwrapping error message that has been wrapped | ||
| // 1. server-side once - /.*failed with error: "(.*)"/ | ||
| // 2. client-side second time - StreamChat error code \d+: | ||
| const originalErrorString = error.message.match( | ||
| /StreamChat error code \d+: .*failed with error: "(.*)"/, | ||
| )?.[1]; | ||
| if (!originalErrorString) return false; | ||
| try { | ||
| const originalError = JSON.parse(originalErrorString) as APIErrorResponse; | ||
| return /field is empty or contains invalid characters/.test(originalError.message); | ||
| } catch (e) { | ||
| return false; | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implementation is quite heuristic. Maybe extend this list with fatal/non-fatal information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed here: a2a15b3
…earch source pagination
|
🎉 This PR is included in version 9.25.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Goal
Closes React-607
Prevent repeating queries with a search string that will always end up in API error response. By default errors are not considered reason to switch
hasNextflag tofalse. Non-retryable errors should however lead to that.Example:
Infinite scroll pagination repeating requests with the same search string that causes the error. Leads to infinite loop.