What could cause a ReferenceError ContextHub is not defined | Community
Skip to main content
Jeanmaradiaga
Level 3
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! 

Jeanmaradiaga
Level 3
April 15, 2021
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?
koenve
Level 2
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