Missing methods in MV3

356 views
Skip to first unread message

Cameron Eckelberry

unread,
Jul 25, 2025, 10:59:44 AM7/25/25
to Chromium Extensions
Anyone else seeing this in MV3?

We have a massive object that contains various methods and variables.
We are randomly seeing issues come up in our Sentry alerts where the method is undefined.
So for example,

const example = {};

example.isTrue = (x) => !!x;

Then executing we randomly get this error:
example.isTrue is not a function

Cameron Eckelberry

unread,
Jul 25, 2025, 1:55:09 PM7/25/25
to Chromium Extensions, Cameron Eckelberry
Forgot to mention, this error occurs in the service worker.

kg_17

unread,
Jul 25, 2025, 5:44:38 PM7/25/25
to Chromium Extensions, Cameron Eckelberry
Do you wait on any async code before initializing the example object?  When your service worker wakes up after an event is fired, it is possible the code in the event listener referencing the example object will run first if that is the case.  For example:

var example = {};
chrome.tabs.onCreated.addListener((tab) => {
    if (example.isTrue(tab.id)) {
        // this may run before the isTrue key is added to the example object.
    }
});
async function initialize() {
    let lStorage = await chrome.storage.local.get();

    example.isTrue = (x) => !!x;
}
initialize();

Cameron Eckelberry

unread,
Jul 29, 2025, 8:48:37 AM7/29/25
to Chromium Extensions, kg_17, Cameron Eckelberry
Yes, every reference is after an async call.


chrome.tabs.onCreated.addListener((tab) => {
    chrome.tabs.get(tab.id, async (tab) => {
        if (!chrome.runtime.lastError) {
             example.isTrue()
        }
    });
});


Is there some document on best practices for ensuring that everything loads?

Oliver Dunk

unread,
Jul 29, 2025, 9:08:45 AM7/29/25
to Cameron Eckelberry, Chromium Extensions, kg_17
I'm not aware of any behavior like this, and it sounds surprising. That would violate how JavaScript is supposed to behave.

Do you see evidence this is happening often? If so, a reproduction would be great.

If not, my hunch would be that this might just be users tinkering with the environment and causing these Sentry reports.
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 visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/6f760ee4-81dd-49d3-b1ce-31f3d1c11a73n%40chromium.org.
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Cameron Eckelberry

unread,
Jul 29, 2025, 11:11:29 AM7/29/25
to Chromium Extensions, Oliver Dunk, Chromium Extensions, kg_17, Cameron Eckelberry
Hey Oliver, I have 12k issues of it in Sentry, so I don't think 

I can share the code separately, but I don't have a solid way to reproduce it unfortunately. We've only seen it once internally, and the error cleared when the user opened the pop out.

Oliver Dunk

unread,
Aug 4, 2025, 10:37:55 AM8/4/25
to Cameron Eckelberry, Chromium Extensions, kg_17
Hmm, that seems really odd.

I'm not aware of any bugs like that, and without steps to reproduce it is going to be hard to troubleshoot. Unless you are particularly concerned I think it would be good to wait for a bit and see if any additional clues come up as to what might be happening.
Oliver Dunk | DevRel, Chrome Extensions | https://developer.chrome.com/ | London, GB

Reply all
Reply to author
Forward
0 new messages