Skip to content

Conversation

@MartinCupela
Copy link
Contributor

@MartinCupela MartinCupela commented Oct 14, 2025

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 hasNext flag to false. 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.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 14, 2025

Size Change: +265 B (+0.07%)

Total Size: 354 kB

Filename Size Change
dist/cjs/index.browser.js 118 kB +86 B (+0.07%)
dist/cjs/index.node.js 119 kB +91 B (+0.08%)
dist/esm/index.mjs 117 kB +88 B (+0.08%)

compressed-size-action

Comment on lines 79 to 93
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;
}
};
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here: a2a15b3

@MartinCupela MartinCupela changed the title feat: recognize fatal errors in search sources fix: prevent search source pagination on non-retryable response errors Oct 14, 2025
@MartinCupela MartinCupela merged commit d306a1a into master Oct 23, 2025
7 of 8 checks passed
@MartinCupela MartinCupela deleted the feat/recognize-fatal-errors-in-search-source branch October 23, 2025 10:58
github-actions bot pushed a commit that referenced this pull request Oct 23, 2025
## [9.25.0](v9.24.0...v9.25.0) (2025-10-23)

### Bug Fixes

* prevent search source pagination on non-retryable response errors ([#1638](#1638)) ([d306a1a](d306a1a))

### Features

* add delivery_events channel configuration parameter ([#1639](#1639)) ([13d295a](13d295a))
@stream-ci-bot
Copy link

🎉 This PR is included in version 9.25.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants