Blog Home » Logging Errors in Web Workers

Logging Errors in Web Workers

By Todd H Gardner

Release 3.8.0 of the TrackJS browser agent added support for Web Workers, which adds some awesome new observability to the background tasks of your web applications.

Many development teams have adopted Web Workers to their web applications to add offline support, caching, or to process heavy tasks. Workers allow web apps to feel faster by removing work from the user interface thread.

But workers are still written in JavaScript, and they still operate in hostile end user browser environments over networks that may not be as reliable as we’d like. Errors will happen.

Enter our hero, TrackJS.

By adding the TrackJS agent to your web workers, you’ll get visibility into all types of errors from your worker processes. Errors like:

  • Globally thrown errors, like Cannot read property 'length' of undefined.
  • Unhandled promise rejections, like TypeError: Failed to Fetch.
  • Network error responses, like 503 :
  • Caught errors from callbacks, like undefined is not an object.
  • Direct or console error messages that you want to pass from your code.

You’ll know right away when there is a problem with your code. Plus, you’ll be able to observe exactly what was happening in the worker thread before the error happened. TrackJS Telemetry in worker threads includes:

  • Method, URL, and time of all network requests.
  • All console messages.
  • Custom metadata about your environment and session.

Plus you’ll get all the great search, filtering, enrichment, and ignore capability that you get with any TrackJS account. Go give it a try today and let us help you build better web applications.

Todd H Gardner
Todd H Gardner
CEO and Cofounder