Why is my Javascript returning undefined?

I’m writing this today to share a solution to a problem my Google-fu couldn’t resolve. Maybe putting this out there will put it in someone else’s search result.

Which terms did I try, you might ask. First of all, behold the title of this post for a hint. Beyond that, a bunch of variations on the below:

“Chrome extension not running javascript correctly for some users”
“Chrome.tabs returns undefined”
“Javascript not running correctly for all users”
“Small usergroup undefined values returned”
“Undefined values returned from previously working code”

Some of you might see where this is going, and to you, I say – post more on StackOverflow! For the rest of you, who may also be stuck in this situation, I have a very simple word: AdBlock. AdBlock. Or is that two words? Ad Block? Anyway.

In a brief and depressing overview of my issue, I’ll say that a Chrome extension I’d been working on to replace a Google form ticket submission process was in final testing stages, and a small group of users were running into errors. The oddest part to me was that it was only a few, and those few hadn’t had issues previously – only in this latest version. What had I added? What might have changed on their end? Was it their Chrome version? No, they had the same ones as those of other testers… I was ready to tear my hair out. That’s when one of the users randomly pinged me with the revelation – “I added the domain to AdBlock whitelist and now it works fine.”

So I can’t really even say that I resolved the issue – just one dedicated tester trying random things until something worked. In summary – if your question is “why is my Javascript returning undefined?” the answer just might be “AdBlock.”

This is the part where you roast me for my poor Google-fu, and my soapboxing of obvious answers. I’m ready.


Published by perlbeforeswine

When I'm not in the office, I can be found hiking in the nearest temperate rainforest or hiding indoors from the heat with my dog, Oliver.

Leave a comment

Design a site like this with WordPress.com
Get started