Skip to content

perf(marketplace): debounce search queries and cancel stale in-flight requests in ExtensionManagerDialog #890

Description

@ZhuchkaTriplesix

Summary

In lib/features/extensions/presentation/pages/extension_manager_dialog.dart, _onSearchChanged is invoked on every single keystroke in the search bar:

Future<void> _onSearchChanged(String query) async {
  if (query.trim().isEmpty) {
    final market = await MarketplaceRepository.instance.getTrending();
    if (mounted) setState(() => _marketplace = market);
  } else {
    final market = await MarketplaceRepository.instance.search(query);
    if (mounted) setState(() => _marketplace = market);
  }
}
  1. No debounce: Typing a query (e.g. "clickhouse") fires 10 concurrent HTTP requests to the marketplace API.
  2. Race condition: Responses can arrive out of order over the network. If the response for "click" arrives after the response for "clickhouse", the search result list will display stale results for "click".
  3. No request cancellation: In-flight network requests are never cancelled when the query changes or when the dialog closes.

Scope

• Add a debounce timer (200–300 ms) to search input in _ExtensionManagerContentState.
• Implement request cancellation or an incremental request token (sequence ID) so only the latest query's response is applied to _marketplace.
• Cancel pending timers and in-flight searches on dialog dispose().

Out of scope

• Redesigning the marketplace backend search API.

Activity

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

Metadata

Metadata

Labels

frontendTheme parser epic label: frontendmarketplaceExtensions marketplace, ExtensionManifestperformanceTheme parser epic label: performanceuxUser experience, keyboard shortcuts and interactions

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions