RE: Reason for "Oops! It looks like this is taking longer than expected."

thumbnail
Dominik Marks, modified 5 Years ago. Regular Member Posts: 149 Join Date: 8/29/12 Recent Posts
We developed a website using Liferay 7.0.6 GA7. We make use of Web Content Templates and Asset Display Templates. Those contain some Javascript, too.


Now when a normal user visits the website (not logged in) sometimes a message "Oops! It looks like this is taking longer than expected." is shown in the top right corner of the website.


I assume that it is caused by a Javascript in one of our templates. How can we track it down to check which Javascript causes this problem? What are the circumstances that this message is displayed? There are no errors in the browser console.
thumbnail
Chema Balsas, modified 5 Years ago. Regular Member Posts: 127 Join Date: 2/25/13 Recent Posts
Hey Dominik!

In other instances of this, we've always concluded that some exception was being thrown by custom code (and caught by Senna) resulting in that endless loading.

First thing I'd try is to enable the "Pause on caught exceptions" setting in your DevTools and see if that points you to the right place.​​​​​​​
thumbnail
Dominik Marks, modified 5 Years ago. Regular Member Posts: 149 Join Date: 8/29/12 Recent Posts
Thanks Chema for your help.

I was able to track it down to a Javascript error inside our templates.

So if I understand you correctly everytime a Javascript error occurs on a page that "Oops"-message is shown? Why? That message does not give a normal user anything, the user cannot do anything about it. 

Maybe a better message would be something like "Hey visitor! The following (Javascript) error occurred: <message here>. Please inform the administrator of this website".
thumbnail
Chema Balsas, modified 5 Years ago. Regular Member Posts: 127 Join Date: 2/25/13 Recent Posts
Hey Dominik!

You are indeed correct... we could do a better job at messaging the issue. The problem if I remember correctly is that we have some try-catch block when evaluating incoming scripts that might make the navigation stop, thus showing the "Ooops" message.

Since this has happened mostly at development time, we haven't fully explored what would be a better option. I don't think showing a stacktrace to the end user would be benefitial at all, but maybe we could log the error in the console so developers are properly notified and show a friendly error message instead of leaving the user hanging in a never-ending loading.

Could you maybe provide a simple reproduction case so we can study that in context and try to come up with a friendlier solution?
Thanks!
thumbnail
Dominik Marks, modified 5 Years ago. Regular Member Posts: 149 Join Date: 8/29/12 Recent Posts
Hey Chema,

I think the most simple test case is the following. Just put the following snippet in a page (using a template or something like that) and navigate to a new page afterwards.

Liferay.on('endNavigate', function() { throw "error!"; });