Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

What could cause a ReferenceError ContextHub is not defined

Avatar

Level 4

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

Avatar

Correct answer by
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

8 Replies

Avatar

Correct answer by
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! 

Avatar

Level 4
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?

Avatar

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.

Avatar

Level 4
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.

Avatar

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.

Avatar

Level 4
That makes sense if nothing is wrong then I'll suggest adding this error to a false positive list. Thanks for the help

Avatar

Level 4

Hi @Asutosh_Jena_ 

 

We're also getting the same error in logs, ContextHub isn't defined, and there are no errors in console.

The Js is rendering correctly on my website's URL. Is there anything else we need to check

Avatar

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