Message from older content script being sent to newer service worker

162 views
Skip to first unread message

Gaurang Tandon

unread,
May 23, 2024, 10:38:17 AMMay 23
to Chromium Extensions
Hi! We use chrome.runtime.sendMessage() in the content script to send a message to the service worker, which is listening to that message via chrome.runtime.onMessage.addListener(). There is a fixed set of message types that the content script can send. If a message with an unknown type is sent to the service worker, it will log an error.

We're currently migrating from Manifest V2 to Manifest V3. So, we removed one message type from both the content script and the service worker (previously background page). Now, we're seeing errors being logged for that message type, even though it no longer exists in the new version of the content script (it only exists for the content script in the older version).

I believe that it should be technically impossible for the orphaned content script (from the old extension version) to communicate with the service worker (of the new version). But, it seems that is happening in this case.

We know that this error only happens when the user updates their extension (after checking for a few users), but we haven't reproduced it yet. Any thoughts about how this can happen? Is this a known issue?

woxxom

unread,
May 23, 2024, 6:39:01 PMMay 23
to Chromium Extensions, Gaurang Tandon
Try reporting it in https://crbug.com. In the web platform an updated service worker can control the existing contexts (pages), so this is what may be happening here as well, in which case it's yet another evidence that the service worker technology makes no sense for extensions that have an entirely different servicing model. Chromium team has wasted thousands of hours on something that has deviated from the original concept of the background scripts, on which it was based, so thoroughly that trying to re-use it for extensions is bound to keep causing subtle bugs and loss of fundamental functionality like dynamic imports, ability to debug the first registration run, live reload of code during development, and various little but important things like URL.createObjectURL for a blob.

Oliver Dunk

unread,
May 24, 2024, 10:04:32 AMMay 24
to woxxom, Chromium Extensions, Gaurang Tandon
Hi Gaurang,

Thanks for sharing this.

This is the first time I'm hearing about something along those lines and it isn't a known issue. It clearly isn't the expected behavior, though.

Do you have any data on the Chrome versions where you are seeing the issue? That is always useful to be sure this wasn't resolved in a recent update.

Beyond that, it would be great if you could try reproducing with the Extension Update Testing Tool: https://github.com/GoogleChromeLabs/extension-update-testing-tool. We can definitely try to troubleshoot without a reproduction but it is of course much easier if we have one, so we can debug locally and figure out what is going on.
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB


--
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/a93f43b2-c409-4ebf-bef2-3bcef3673525n%40chromium.org.

Gaurang Tandon

unread,
May 24, 2024, 11:59:20 AMMay 24
to Chromium Extensions, Oliver Dunk, Chromium Extensions, Gaurang Tandon, woxxom
Thanks both for your responses!

I have posted this on crbug: https://issues.chromium.org/issues/342602612
These errors are happening in Chrome 125 and earlier versions. I will try to reproduce using the update testing tool.

Oliver Dunk

unread,
May 28, 2024, 5:58:14 AMMay 28
to Gaurang Tandon, Chromium Extensions, woxxom
Thanks Gaurang!

To confirm, are you saying the issue is resolved in Chrome 126 or just that you don't have enough data for that release yet? I'm assuming the latter, but wanted to be sure.

Thanks,
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB

Gaurang Tandon

unread,
May 28, 2024, 6:00:38 AMMay 28
to Chromium Extensions, Oliver Dunk, Chromium Extensions, woxxom, Gaurang Tandon
Yes, we don't have enough data for the Chrome 126 release yet.

Oliver Dunk

unread,
May 28, 2024, 6:03:53 AMMay 28
to Gaurang Tandon, Chromium Extensions, woxxom
No worries - I've already passed this on internally.

Once you have enough data, could you share an update there? It goes to stable on June 11th so hopefully there will be more logs by that point.

In the meantime, do you have any data around what number / percentage of your users are impacted?

Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB

Gaurang Tandon

unread,
May 30, 2024, 1:52:04 AMMay 30
to Chromium Extensions, Oliver Dunk, Chromium Extensions, woxxom, Gaurang Tandon
It's hard to estimate exactly, but I think around 4-5% of our users who updated from MV2 to MV3 got this issue.
Reply all
Reply to author
Forward
0 new messages