chrome.tabs.onUpdated listener not fired

1,290 views
Skip to first unread message

Browser Extenstion

unread,
Jun 17, 2022, 5:34:56 AM6/17/22
to Chromium Extensions
Hello,

I have a problem with chrome.tabs.onUpdated listener on MV3.
If service worker is inactive the chrome.tabs.onUpdated listener not fired.
If service worker is active (or open via Inspect views) the code works as expected.

One more notice: the code always works in MV2 (with background page).

Sample of the code:
function  Listener (tabId, changeInfo, tab) {
        console.log('here'); <-- not fired
        some_code_goes_here();
}
chrome.tabs.onUpdated.addListener(Listener);

Browser Extenstion

unread,
Jun 17, 2022, 9:04:26 AM6/17/22
to Chromium Extensions, Browser Extenstion
Additional information about the bug:
The problem relevant not only to chrome.tabs.onUpdated/onActivated, but for chrome.webNavigation, chrome.webRequest and chrome.runtime.onMessage/onConnect listeners as well.
One of the bug report you can find here:  crbug.com/1024211
I have checked on Version 105.0.5123.0 (Official Build) canary (64-bit) and the problem still there

In order for the extension to work I need to create "persistent" service worker.
Now, I have 2 options to workaround to support chrome.tabs.onUpdated.addListener:
1. Use "scripting" permission with <all_urls> in order to create runtime port and reconnect it before 5 minutes elapse.
2. Content script with the same permissions and purpose.

For my extension I do not need scripting permission other than the problem described above.
I'm not using content script at all.

So I have a question to Simeon - @dotproto:

How can it be that the new service worker breaks the basic functionality of the chrome API and no one is going to solve this problem (in any case, I did not find a description somewhere that the problem will be solved in the "N" version of chrome) ?

Jói Sigurdsson

unread,
Jun 17, 2022, 4:24:22 PM6/17/22
to Chromium Extensions, Browser Extenstion
Hi, I wonder if you might be running into this issue with MV3 extensions where they sometimes get into a bad state where the service worker does not wake up for external events: https://bugs.chromium.org/p/chromium/issues/detail?id=1271154

If that's the case then disabling and re-enabling your extension would most likely work around the issue.

If you think it's the same bug then I suggest starting the issue (click the link, log in with Google account and star near top left) and commenting on it to confirm you are seeing the same issue.

Best regards,
Jói

Browser Extenstion

unread,
Jun 18, 2022, 9:51:54 AM6/18/22
to Chromium Extensions, Jói Sigurdsson, Browser Extenstion

I have created new bug report crbug.com/1337294 with extension example and video shows that the chrome.tabs.onUpdated.addListener() not fired if the service worker is inactive.
Feel free to vote for this issue.
I think it is a critical moment before moving to MV3.
Reply all
Reply to author
Forward
0 new messages