Aggressive repeated get user calls inside update widget causing 429 too many requests
Which packages are you using?
stream_chat
On what platforms did you experience the issue?
iOS
What version are you using?
8.0.0 (I checked 8.1.0 there isn't a mention of fixing this and I have bunch of dependencies that I can't upgrade to 8.1.0 yet)
What happened?
User list screen was presented with showDialog (followed from sample code):
void _buildAddUserModal(context) {
showDialog(
useRootNavigator: false,
context: context,
barrierColor: StreamChatTheme.of(context).colorTheme.overlay,
builder: (context) {
return Padding(
padding: const EdgeInsets.only(top: 16.0, left: 8.0, right: 8.0),
child: Material(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
),
clipBehavior: Clip.antiAlias,
child: Scaffold(
body: Column(
children: [
Padding(
padding: const EdgeInsets.all(16),
child: _buildTextInputSection(),
),
Expanded(
child: StreamUserGridView(
controller: _userListController,
onUserTap: (user) async {
_searchController.clear();
final navigator = Navigator.of(context);
await channel.addMembers([user.id]);
navigator.pop();
setState(() {});
},
emptyBuilder: (_) {
return LayoutBuilder(
builder: (context, viewportConstraints) {
return SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: viewportConstraints.maxHeight,
),
child: Center(
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(24),
child: StreamSvgIcon.search(
size: 96,
color: StreamChatTheme.of(context).colorTheme.textLowEmphasis,
),
),
Text(
LocaleKeys.stream_chat_no_user_matches_these_keywords.tr(),
style: StreamChatTheme.of(context).textTheme.headline,
),
],
),
),
),
);
},
);
},
),
),
],
),
),
),
);
},
).whenComplete(() {
_searchController.clear();
});
}
The following screenshot from opening the screen once.
The problem I traced to is this code
@override
void didUpdateWidget(covariant PagedValueGridView<K, V> oldWidget) {
super.didUpdateWidget(oldWidget);
if (_controller != oldWidget.controller) {
// reset duplicate requests flag
_hasRequestedNextPage = false;
_controller.doInitialLoad();
}
}
_controller.doInitialLoad() gets repeatedly called with didUpdateWidget in paged_value_scroll_view.
I tapped three time and triggered 429. (Sometime it would fail on the first try)
https://github.com/user-attachments/assets/d3b31c4b-1dae-4145-bcf9-edb70ec617ae
Steps to reproduce
Video captured above
Supporting info to reproduce
No response
Relevant log output
No response
Flutter analyze output
No response
Flutter doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.6.1 23G93 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.4)
[✓] VS Code (version 1.93.1)
[✓] Connected device (4 available)
[✓] Network resources
• No issues found!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
This issue is stale because it has been open for 20 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.
This issue is stale because it has been open for 20 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.