Skip to content

Automatic updates seem to never happen #3190

@binki

Description

@binki

I have a script which I updated on 2024-04 but one of my browsers says it last updated it on 2023-05-22. Automatic updates is on and everything.

When investigating, I looked at the code in the debugger. I think I found two issues.

Lack of updateNextAt value

if (!nextTime || !nextUuid || v < nextTime) {

I also found that only one of my scripts had a updateNextAt. value set in chrome.storage.local.get().

It seems that v < nextTime will evaluate to false when v is undefined and nextTime is some positive number:

> undefined < 10
false

I think that the intention is that any script without a updateNextAt. value automatically be scheduled for an immediate update check. What the actual current logic appears to be is that any script which had ever successfully updated in the past will update. It seems impossible for more than one script to ever have an updateNextAt. value set for it unless if the user debugs the extension and manually adds keys. So I think that either v === undefined should be added to the list of short-circuiting conditions or v should be coalesced to 0 when its value is not present in chrome.storage.local.

To explain in more detail: it seems that on one of my systems, only one script gets updated due to this issue. On another system, only 7 of 14 or so eligible scripts gets updated. The reason that sometimes multiple scripts actually can get their updateNextAt. value set depends on the order that script UUIDs are added to the updateNextAtKeys variable. As long as a newly added script which does not have an updateNextAt. value yet is the first key in updateNextAtKeys during at least one auto-update check, then it will, as the author intended, be considered eligible for updating and join the list of scripts which are capable of auto-updating (due to successfully having its updateNextAt. value set during that update check).

Lack of Error Tolerance

At

await checkForUpdate(nextUuid);
I see a call to a function which can throw (i.e., awaiting a Promise which can be rejected). In the above example, when checking the values on one of my computers, the one updateNextAt. value I saw in the system was set to a value in the past. Since this is running on a browser which might be left open for weeks on a computer which does sometimes enter a low power state, I suspect, but cannot prove, that the update checks of even that one script ended up paused due to updates never being rescheduled after a download failure. I think a try{}finally{} construct is in store here. This would enable the extension to continue checking for updates even if the scheduled update occurs when the system is offline.

Please let me know if PRs would be helpful.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions