Skip to content

Fix LocalStorage observeChanges ignores later keys#6902

Merged
TimoPtr merged 2 commits into
home-assistant:mainfrom
zry98:fix/LocalStorage-observeChanges
May 26, 2026
Merged

Fix LocalStorage observeChanges ignores later keys#6902
TimoPtr merged 2 commits into
home-assistant:mainfrom
zry98:fix/LocalStorage-observeChanges

Conversation

@zry98
Copy link
Copy Markdown
Contributor

@zry98 zry98 commented May 25, 2026

Summary

In LocalStorageImpl.observeChanges, awaitClose was placed inside the keys.forEach loop, the coroutine suspended after the first iteration, so the listeners for the remaining keys were never registered. The first key was effectively the only one observed, changes to later keys are ignored silently.

This fix replaces the per-key listeners with a single listener that filters by the watched key set and registers/unregisters once.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Copy link
Copy Markdown
Member

@TimoPtr TimoPtr left a comment

Choose a reason for hiding this comment

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

Thanks for catching this 👍🏻 it is my mistake ...

@TimoPtr TimoPtr changed the title fix(LocalStorage): observeChanges ignores later keys Fix LocalStorage observeChanges ignores later keys May 26, 2026
@TimoPtr TimoPtr merged commit f0ca05d into home-assistant:main May 26, 2026
30 of 32 checks passed
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.

2 participants