What could cause a ReferenceError ContextHub is not defined | Community
Skip to main content
Jeanmaradiaga
April 14, 2021
Solved

What could cause a ReferenceError ContextHub is not defined

  • April 14, 2021
  • 2 replies
  • 3404 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Asutosh_Jena_

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! 

2 replies

Asutosh_Jena_
Community Advisor
Asutosh_Jena_Community AdvisorAccepted solution
Community Advisor
April 15, 2021

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! 

Asutosh_Jena_
Community Advisor
Community Advisor
April 15, 2021
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.
koenve
April 15, 2021

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