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

Inconsistency: storage onChanged #511

Open
erosman opened this issue Dec 23, 2023 · 4 comments
Open

Inconsistency: storage onChanged #511

erosman opened this issue Dec 23, 2023 · 4 comments
Labels
implemented: chrome Implemented in Chrome implemented: safari Implemented in Safari supportive: firefox Supportive from Firefox topic: storage Issues related to persisting data. Topics include browser.storage, web storage, and new APIs.

Comments

@erosman
Copy link

erosman commented Dec 23, 2023

Inconsistency: storage onChanged

I have comes across an inconsistency in the return of the storage onChanged event.
(I am not aware of the return from other browsers.)

Example:

// same for browser and chrome APIs
browser.storage.onChanged.addListener()
browser.storage.sync.onChanged.addListener()

Firefox

  • Returns all values, changed or not
  • Event is dispatched regardless of the changed values

Chrome

  • Chrome returns only the changed values
  • Event is not dispatched if there are no changed values

See also:

@hanguokai
Copy link
Member

This issue discusses the behavior of onChanged listener:

  • when set() an item, whether to compare its value has changed.
  • when remove() an item, whether to compare the item already removed.
  • when clear(), whether to compare the storage already empty.

In addition, what is the behavior of storage.sync when it syncs with the cloud (remote values)?

@tophf
Copy link

tophf commented Dec 26, 2023

what is the behavior of storage.sync when it syncs with the cloud (remote values)

AFAIK the API considers the local copy (cache) to be fully representative of the remote state.

@Rob--W Rob--W added implemented: chrome Implemented in Chrome implemented: safari Implemented in Safari supportive: firefox Supportive from Firefox topic: storage Issues related to persisting data. Topics include browser.storage, web storage, and new APIs. and removed needs-triage labels Jan 4, 2024
@Rob--W
Copy link
Member

Rob--W commented Jan 4, 2024

Adding consensus labels - everyone is in favor of only firing storage.onChanged when there are changes in values. Firefox is the only one that sometimes fires onChanged despite there not being any changes. This issue is tracked at https://bugzilla.mozilla.org/show_bug.cgi?id=1833153

@oliverdunk
Copy link
Member

The other discrepancy in the original issue was if the event should fire with all values in the storage area, or just the changed ones. Given the current behaviour in Chrome is to only include the changed values, I'm reluctant to look at changing that unless there are strong reasons to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
implemented: chrome Implemented in Chrome implemented: safari Implemented in Safari supportive: firefox Supportive from Firefox topic: storage Issues related to persisting data. Topics include browser.storage, web storage, and new APIs.
Projects
None yet
Development

No branches or pull requests

5 participants