slanatech / swagger-stats

API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.
https://swaggerstats.io/
MIT License
886 stars 136 forks source link

ReferenceError: that is not defined #286

Closed Tomas2D closed 2 months ago

Tomas2D commented 2 months ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch swagger-stats@0.99.7 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/swagger-stats/lib/swsElasticEmitter.js b/node_modules/swagger-stats/lib/swsElasticEmitter.js
index 6c44a9b..cd1c1c5 100644
--- a/node_modules/swagger-stats/lib/swsElasticEmitter.js
+++ b/node_modules/swagger-stats/lib/swsElasticEmitter.js
@@ -280,7 +280,7 @@ swsElasticEmitter.prototype.flush = function(){
         }
     }).catch((error)=>{
         debug(`Indexing Error: ${error.message}`);
-        that.enabled = false;
+        this.enabled = false;
     });

     this.indexBuffer = '';

This issue body was partially generated by patch-package.

Tomas2D commented 2 months ago

Duplicate: #279