CWS Updates: requestUpdateCheck + reload Behavior

302 views
Skip to first unread message

Gokulan Gnanendran

unread,
Sep 1, 2024, 4:28:08 PM9/1/24
to Chromium Extensions
Hey team, 

I have an extension that communicates with backend services which may require the extension to be updated to a certain version. I am using the strategy described in the `chrome.runtime.requestUpdateCheck()` documentation here:

  • When the extension detects that it is out-of-date, it shows the user an update prompt.
  • When the user clicks the button on the prompt, the handler calls `requestUpdateCheck`. 
  • If `requestUpdateCheck` reports that `update_available`, then the extension calls `chrome.runtime.reload()`.
  • After the update is installed, the extension performs some setup work in response to the `onInstalled` event in the background script.

This normally works fine. However, while testing (via a beta extension), I noticed that the extension was not updated after calling `chrome.runtime.reload()` even though `requestUpdateCheck` reported that an update (with the expected `available_version`) was available. Note: I have been facilitating testing by rolling back builds while bumping the build number.

I have a few questions around this:
  • Did this occur due to how I've been testing?
    • Are my updates potentially too frequent?
  • Is there a way to simulate CWS extension updates?
  • Is there a way to ensure that an update will occur before calling chrome.runtime.reload()?
  • Is there an existing way to detect that a `chrome.runtime.reload()` has occurred?
    • I'd use this instead of onInstalled.
Let me know if you have any questions or have any alternate suggestions!

Thanks,
Goki

Patrick Kettner

unread,
Oct 14, 2024, 4:28:17 PM10/14/24
to Gokulan Gnanendran, Chromium Extensions
Hi Gokulan!

> I noticed that the extension was not updated after calling `chrome.runtime.reload()` even though `requestUpdateCheck` reported that an update (with the expected `available_version`) was available. 

Thats unexpected! Are you able to reproduce the issue at all? Or was this a one time occurrence?

> Did this occur due to how I've been testing?
Based on what you mentioned, it sounds like a bug. If you call requestUpdateCheck too frequently will result it in being throttled, but if it is returning an update being available runtime.reload should give you that new version.

> Are my updates potentially too frequent?
If its an updated submitted to the store that is approved and now live, it isn't too frequent.

> Is there a way to simulate CWS extension updates?
Just the tool you mentioned

> but this still requires updates to be applied via clicking update in chrome://extensions
As opposed to what? Calling chrome.runtime.reload() would trigger the same reload behavior. If you can show a reproducible case where this is not the case, please open a bug at crbug.com/new

 > Is there an existing way to detect that a `chrome.runtime.reload()` has occurred?
This is what onInstalled is for.

best
patrick







--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/ca8ef1d7-8b5e-4c7b-99e1-844a7e0c6fb5n%40chromium.org.

Oliver Dunk

unread,
Oct 15, 2024, 11:12:16 AM10/15/24
to Patrick Kettner, Gokulan Gnanendran, Chromium Extensions
Hi Goki,

To add a bit to what Patrick said from my experience:
  • Updating an extension installed with the extension-update-testing-tool should work, even if you use `chrome.runtime.reload()`
  • It's been a while, but the last time I was looking at this code I think I identified an issue where we would sometimes report an update before we had finished downloading it. Is your extension particularly large, or do you have a slower internet connection? If so, it's possible that may be responsible for what you're seeing.
Thanks,
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB


Reply all
Reply to author
Forward
0 new messages