How do I troubleshoot chrome.storage.sync?

I have a simple Chrome extension that uses the chrome.storage API to store tasks in a list. Every time the task list is updated, the array is stored in chrome.storage.sync.

I have two laptops configured with a Chrome extension. I am logged into the same google account on both.

Sometimes when I update the task list on the first laptop, the second laptop will reflect the update in a matter of seconds. But in other cases, the second laptop will not receive updates for a long time. This is very controversial - sometimes if I leave Chrome and restart it on a second computer, the updated list will be there.

I don't get any console errors on any laptop, and the tasks are saved correctly on the first computer - they just don't get transferred to the second laptop.

chrome.storage.sync API has several limitations and I'm trying to figure out if I'm punching one of them. The most likely one:

10 MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE

      

"The maximum number of install, uninstall, or cleanup operations that can be performed every minute is over 10 minutes. Updates that may exceed this limit are immediately terminated and set runtime.lastError."

The way I read this is that if for 10 consecutive minutes (no less than 100) there are no more than 10 operations per minute, the limit will not be breached. And if I violate this limit, I see a console error or tasks will not be saved locally.

In general - is there a way to debug Chrome sync issues? Is it expected to be scaly?

+3


source to share


1 answer


There are problems with reliance on chrome.storage.sync

, yes.

  • The quota limitation can blacklist your extension in memory until Chrome restarts.

    In theory, you can catch a callback quota error chrome.storage.set

    as it will install chrome.runtime.lastError

    and implement some kind of defer / buffering function.

    In practice, there is anecdotal evidence that Chrome (and not Google's backend) blacklists extensions that violate limits, and this persists across the Chrome session (even if the quota needs to be updated). This is still not fixed as of 2014-10-16.

  • Unable to wait / request sync.

    Unfortunately, chrome.storage.sync

    in its current form, it does not provide an event to complete a remote sync, or has an error in case there is no change to the local state. Thus, if you rely on some value at startup, you cannot reliably wait for it . And as pointed out by the Chrome devs, it will probably stay that way.

  • Status information is not displayed.

    Actually, forget about the events. The API doesn't even reveal if Chrome Sync is enabled. Many problems would have been resolved if this had been done and the last known sync timestamp was set. This is not the case at present; here is a feature request .

Despite this, it chrome.storage.sync

is a useful tool. However, when using it, expect it to be unreliable and always respect speed limits; perhaps implement your own speed limit.



To answer your question

For debugging, chrome.storage.sync

you can look under the hood using the chrome://sync-internals

page.

+5


source







All Articles