kill scripts

A Kill Script For Processes That Are Using TCP/UDP Ports

April 24, 2020
embedding website links into your android app

Embedding Website Links Into Your Android App

June 25, 2020

Unhandled Promises Sent Through To App Insights In Node JS

June 23, 2020 / Tielman Janse van Vuuren

App Insights is great for monitoring services, logging metrics and analysing traces and exceptions. However I recently came across an issue where unhandle promises rejections showed up in App Insights as [object Promise]. Which is fine however the stack trace was not very helpful, showing that the error was thrown in the appinsights package itself.

The auto exception tracking feature of the appinsights node module catches unhandled Promise rejections which is great, but it doesn’t extract the message from them. In fact it checks whether the object it receives for tracking is an Error and when it finds out that it is not error, it throws an internal Error which is where the stack trace comes from.

To show the info inside a promise rejection, I made a wrapper around the trackException function on the defaultClient:

https://gist.github.com/tmanOC/db82dba5d01612e92f7bd0b1891aac7c


The trackException wrapper function receives the object in telemetry.exception and tests whether it is a Promise and handles it accordingly, extracting the message from the Promise and changing the telemetry object before passing it on to the original trackException function.

Share

Tielman Janse van Vuuren

Tielman is an experienced mobile and backend developer. Quality is his motto, no matter what programming language or platform.

Unhandled Promises Sent Through To App Insights In Node JS
This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy.
Read more