Skip to content
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

Aggressive repeated get user calls inside update widget causing 429 too many requests #2026

Open
1 task done
pixnbit opened this issue Sep 22, 2024 · 2 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@pixnbit
Copy link

pixnbit commented Sep 22, 2024

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.

image

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)

ScreenRecording_09-22-2024.16-20-02_1.MP4

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

  • I agree to follow this project's Code of Conduct
@pixnbit pixnbit added the bug Something isn't working label Sep 22, 2024
Copy link

This issue is stale because it has been open for 20 days with no activity.

@github-actions github-actions bot added the Stale label Oct 13, 2024
Copy link

This issue was closed because it has been inactive for 7 days since being marked as stale.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2024
@deven98 deven98 removed the Stale label Oct 23, 2024
@deven98 deven98 reopened this Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants