12

Debugging little javascript errors has become a nightmare (again.. feel like this is how it was a year ago and earlier). Simple errors it seems, like referencing a controller method that does not exist, give obfuscated errors now. Take this example, create the component below and add it to a page in a lightning community.

Simple component

<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
</aura:component>

Now create a handler but leave it as it is by default/make sure it does not have a method called doInit. In a winter 19 org you get the error I mentioned, "This page has an error. You might just need to refresh it. [NoErrorObjectAvailable] Script error."

However, the same exact component in a summer 18 org gives you the error you can actually reasonably debug, since it says which component it is and what the problem is:

"This page has an error. You might just need to refresh it. Unknown controller action 'doInit' Callback failed: serviceComponent://ui.comm.runtime.components.aura.components.siteforce.controller.PubliclyCacheableComponentLoaderController/ACTION$getPageComponent Failing descriptor: {markup://c:testingErrors}"

This seems to be happening with almost all the javascript errors, like mishandling a return value from an apex controller, etc. When these components are nested and you're working with a bunch.. it is completely untenable to debug if we don't even have the identity of the component (referrals to developer therapists?).

4
  • I would submit this with SFDC directly, in fact open up a case ticket with them.
    – ensir
    Apr 26, 2019 at 22:14
  • Can you provide the code for your javascript controller and helper?
    – Robs
    Apr 26, 2019 at 22:17
  • 1
    Have you tried debugging by inspecting the component and applying breakpoints in your JS code ? This has served as the best way to debug Lightning JS code for me. Jun 4, 2019 at 5:40
  • add a try-catch block in the JS method (a best practise as well) and you will have more details in the error object which will clearly state which line error originated
    – GirishP
    Jun 14, 2021 at 16:18

1 Answer 1

0

I was facing this issue as well when testing components in salesforce https://speed-power-9666-dev-ed.lightning.force.com/one/one.app

Error in main app

But when testing the same component in a custom lightning app https://speed-power-9666-dev-ed.lightning.force.com/c/customApp.app I receive a much more useful response

Error in custom app

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.