You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As per subject, the public "dispose()" method in the main ApplicationInsights class calls "dispose()" on each internal static instances of console, exceptions, performance and requests. But in the implementation of those methods, not all resources are released. As an example:
classAutoCollectExceptions{
...
publicenable(isEnabled: boolean){if(isEnabled){
...
process.on("uncaughtException",this._exceptionListenerHandle);}}else{
...
process.removeListener("uncaughtException",this._exceptionListenerHandle);
...
}}}publicdispose(){AutoCollectExceptions.INSTANCE=null;// <<<<---- What about calling "this.enable(false)" here?this._isInitialized=false;}
Same goes for performance.
In my tests I use the "dispose()" method to reset AI's SDK to a pristine state. This is required because AI creates a global singleton and even reloading it with another require(), the same instance is returned due to node's module caching.
After some tests, node complains about an handler leek because handlers are added on each test.
My suggestion is to call "enable(false)" in the dispose call if you agree. I can make a PR for this if you like.
The text was updated successfully, but these errors were encountered:
As per subject, the public "dispose()" method in the main ApplicationInsights class calls "dispose()" on each internal static instances of console, exceptions, performance and requests. But in the implementation of those methods, not all resources are released. As an example:
https://github.com/Microsoft/ApplicationInsights-node.js/blob/master/AutoCollection/Exceptions.ts
Same goes for performance.
In my tests I use the "dispose()" method to reset AI's SDK to a pristine state. This is required because AI creates a global singleton and even reloading it with another require(), the same instance is returned due to node's module caching.
After some tests, node complains about an handler leek because handlers are added on each test.
My suggestion is to call "enable(false)" in the dispose call if you agree. I can make a PR for this if you like.
The text was updated successfully, but these errors were encountered: