Skip to content

fix: remove broken stale request check and handle network errors in autocomplete#7441

Open
Sherley-Sonali wants to merge 3 commits intoopenfoodfacts:developfrom
Sherley-Sonali:fix/autocomplete-stale-requests
Open

fix: remove broken stale request check and handle network errors in autocomplete#7441
Sherley-Sonali wants to merge 3 commits intoopenfoodfacts:developfrom
Sherley-Sonali:fix/autocomplete-stale-requests

Conversation

@Sherley-Sonali
Copy link

@Sherley-Sonali Sherley-Sonali commented Mar 7, 2026

⚠️ Acceptance Requirements

What

  • Removed the broken time-based stale request check in _getSuggestions.
    start.difference(DateTime.now()).inSeconds always returns a negative value,
    so the condition > 5 never triggered. This was dead code.
  • Stale request ordering is already handled correctly by AutocompleteManager
    in openfoodfacts-dart, this confirms the "to be confirmed" from the issue discussion.
  • Fixed silent catch block: on network failure, the loading spinner now always
    hides and empty results are returned cleanly instead of leaving the user
    with a stuck spinner.

Screenshot or video

No visual change — this is a logic fix. Spinner now correctly disappears
on network failure instead of staying indefinitely.

Fixes bug(s)

Part of

@github-actions github-actions bot added ✏️ Editing Many products are incomplete and don't have Nutri-Score, Eco-Score…so editing is important for users autocomplete labels Mar 7, 2026
@teolemon teolemon requested a review from a team March 7, 2026 09:27
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

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

Hi @Sherley-Sonali!
The first step would be to format your code, cf. dart format .

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

Labels

autocomplete ✏️ Editing Many products are incomplete and don't have Nutri-Score, Eco-Score…so editing is important for users

Projects

Status: 💬 To discuss and validate

Development

Successfully merging this pull request may close these issues.

Auto-completion is often very slow

2 participants