Fopa Léon Constantin
Fopa Léon Constantin

Reputation: 12363

How to troubleshoot client-side Javascript errors that you cannot reproduce at home?

I'm having trouble getting the details of javascript errors that occur on 2 pages of my online shopping site.

The site was built in Zend Framwork 2 and is in production.

The error is raised at the client level and prevents the client from sending requests to continue its purchasing process.

This error only occurs on certain customers (3 over 10 which is big).

After interviewing these clients, nothing special helps to distinguish them and often the problem no longer appears for some of them.

As a result, I cannot reproduce this behavior personally.

I tested Chrome Version 79.0.3945.88 (Official build) (64 bits).

I don't see any trace of the error in my log file on the PHP server side /etc/apache2/log/error_log.log

I learned about this bug on my site only through customer feedback.

This allowed me to set up a monitoring of suspicious pages by taking inspiration from this article by

Capture and report JavaScript errors with window.onerror

window.onerror = function (msg, url, lineNo, columnNo, error) {
  // ... handle error ...

  return false;
}

On the other hand, the information returned by this function does not allow me to understand the error or reproduce it

Here is an example of a saved line

230: Uncaught TypeError: undefined is not a function https://www.blablabla.com/2362884074c65a8ac1f5e586/111022

How to troubleshoot Javascript errors that you cannot reproduce at home?

How to better collect the logs of this error (console.log)?

Upvotes: 0

Views: 245

Answers (1)

soulston
soulston

Reputation: 29

There are a number of services which can help you with this such as https://logrocket.com and https://sentry.io.

There is quite an old Stack Overflow post on this subject although it does cover most of the important points: Error-logging for javascript on client side

Upvotes: 1

Related Questions