Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

What could cause a ReferenceError ContextHub is not defined

Jeanmaradiaga
Level 3
Level 3

My project is using Bugsnag to catch errors in our AEM site, one recurring error is:

ReferenceError/en
ContextHub is not defined
 
The stack trace shows the following sequence of events: 
 
XMLHttpRequest succeeded
DOMContentLoaded
 
Page Loaded
Page Shown
ReferenceError: ContextHub is not defined
 
 

 

[
  {
    "file": "https://www.site.com/etc/cloudsettings.kernel.js/conf/global/settings/cloudsettings/company/contexthub",
    "method": "Object.<anonymous>",
    "lineNumber": 348,
    "columnNumber": 78
  },
  {
    "file": "https://www.site.com/etc/cloudsettings.kernel.js/conf/global/settings/cloudsettings/company/contexthub",
    "method": "m",
    "lineNumber": 96,
    "columnNumber": 350
  },
  {
    "file": "https://www.site.com/etc/cloudsettings.kernel.js/conf/global/settings/cloudsettings/company/contexthub",
    "method": "Object.fireWith [as resolveWith]",
    "lineNumber": 98,
    "columnNumber": 75
  },
  {
    "file": "https://www.site.com/etc/cloudsettings.kernel.js/conf/global/settings/cloudsettings/company/contexthub",
    "method": "b",
    "lineNumber": 172,
    "columnNumber": 434
  },
  {
    "file": "https://www.site.com/etc/cloudsettings.kernel.js/conf/global/settings/cloudsettings/company/contexthub",
    "method": "XMLHttpRequest.<anonymous>",
    "lineNumber": 182,
    "columnNumber": 160
  }
]

 

 

After that the page load perfectly, no rendering errors, no console errors.

1 Accepted Solution
asutosh_jena
Correct answer by
Community Advisor
Community Advisor

Hi @Jeanmaradiaga 

 

Do you see the content when you try to access the below URL in your website?

https://www.site.com/etc/cloudsettings.kernel.js/conf/global/settings/cloudsettings/company/contexthub

It should render the JS if it's working as expected.

 

If it's not loading that means there is a configration issue and the JS file is not loading which is why the tool is throwing ContextHub is not defined error.

 

Thanks! 

View solution in original post

7 Replies
asutosh_jena
Correct answer by
Community Advisor
Community Advisor

Hi @Jeanmaradiaga 

 

Do you see the content when you try to access the below URL in your website?

https://www.site.com/etc/cloudsettings.kernel.js/conf/global/settings/cloudsettings/company/contexthub

It should render the JS if it's working as expected.

 

If it's not loading that means there is a configration issue and the JS file is not loading which is why the tool is throwing ContextHub is not defined error.

 

Thanks! 

View solution in original post

Jeanmaradiaga
Level 3
Level 3
Hello @asutosh_3 I went to my site's URL and it did render the JavaScript correctly (albeit minified, but that's okay). This error is really not having any negative effect on the site, it is just being logged multiple times a day. Could this just be a false positive caused during the page loading process?
asutosh_jena
Community Advisor
Community Advisor
I do not think it has anything to do with page load process. If it's loading as expected and there is no impact on the functionality, then it could be a false positive by the tool. Having said that we need to ensure, we are following the correct process to validate using the tool.
Jeanmaradiaga
Level 3
Level 3
Do you have any suggestions? We have been having this same issue for around 4 years now. No one has come close to identifying why or how it is happening.
asutosh_jena
Community Advisor
Community Advisor
I have not used this tool so far. So I will not able to say how this actually crawls the websites and identifies the possible issue. But you can run your website through the broken link test just to ensure that the links that are used on the website are returning 200 and all the functionality are working as expected.
Jeanmaradiaga
Level 3
Level 3
That makes sense if nothing is wrong then I'll suggest adding this error to a false positive list. Thanks for the help 🙂
koenve
Level 3
Level 3

Hey!

 

The AEM project archetype creates a page component for you when initialising your project. That page is including the contexthub code in your page. If you’re not using contexthub (and you’re not planning to use it either) you’re safe to remove it from your code.

 

You should find something back under your page component in “customheaderlibs.html”:

<sly data-sly-resource="${'contexthub' @ resourceType='granite/contexthub/components/contexthub'}"/>

 If you remove this line, the error shouldn’t appear anymore.

Hope this helps!

Koen