Runtime Errors Medium

Fix uncaught JavaScript errors

Uncaught JavaScript exceptions can stop execution partway through a script, silently breaking whatever functionality was supposed to run after the failure point (a form that no longer submits, a menu that no longer opens) without any visible error to the user. They are functionally worse than console errors that come from optional third-party scripts, because they usually indicate a bug in the site's own code.

Why it matters

Uncaught JavaScript exceptions can halt script execution partway through, breaking forms, navigation, or interactive features for real users without any visible warning.

How to fix

  1. 1 Reproduce the error and inspect the stack trace.
  2. 2 Add proper error handling or fix the root cause (undefined variables, failed assumptions, etc.).
  3. 3 Add monitoring (e.g. Sentry) to catch regressions early.

Common mistakes

  • Wrapping the failure point in a try/catch that silently swallows the error instead of fixing the root cause, hiding the symptom while the underlying bug remains.
  • Reproducing the error in one browser/environment and assuming the fix applies everywhere, when the root cause (e.g. a missing polyfill) might only manifest in specific browsers.
  • Fixing the immediate crash without checking whether earlier interactions left the page in an inconsistent state.

How to verify

  1. 1 Open devtools console and reproduce the flow that previously threw the error, confirming it now completes without exceptions.
  2. 2 Check the stack trace against the fixed code to confirm the actual root cause was addressed, not just a symptom.
  3. 3 Add error monitoring (e.g. Sentry) to catch regressions in production traffic, which often surfaces edge cases a manual test misses.

Related checks

Ready to see where you stand?

Scan your site and get your Engineering Score with a prioritized roadmap in under a minute, no signup required.

Scan your site