Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InFlight counter going negative #160

Open
PrestonGiorgianni opened this issue Oct 27, 2021 · 0 comments
Open

InFlight counter going negative #160

PrestonGiorgianni opened this issue Oct 27, 2021 · 0 comments

Comments

@PrestonGiorgianni
Copy link

Hello, I was working on making sure all the Logs from Winston were flushed before my app quit. When trying to check that all of the logs that had made it into Syslog were send I found a few issues, my first issue was with the inFlight variable not being updated on the two places the project uses this.socket.write, leading to a negative number of inFlight messages. The second issue I was having is that if I remove the transport from a logger, the socket becomes not writeable, and there is no check around this.socket.write, causing random unhandled exceptions.

Here are the changes that I made for the first issue, If the project is accepting PRS, I can go ahead and put these chagnes into one.

diff --git a/node_modules/winston-syslog/lib/winston-syslog.js b/node_modules/winston-syslog/lib/winston-syslog.js
index 5b1e9f0..4d98d0e 100644
--- a/node_modules/winston-syslog/lib/winston-syslog.js
+++ b/node_modules/winston-syslog/lib/winston-syslog.js
@@ -181,6 +181,7 @@ class Syslog extends Transport {
   // metadata, `meta`, to the specified `level`.
   //
   log(info, callback) {
     let level = info[LEVEL];
     if (!~levels.indexOf(level)) {
       return callback(
@@ -252,6 +253,7 @@ class Syslog extends Transport {
       if (this.isDgram) {
         sendDgram();
       } else {
+        this.inFlight++;
         this.socket.write(syslogMsg, 'utf8', onError);
       }
 
@@ -389,6 +391,7 @@ class Syslog extends Transport {
         // When the socket is ready, write the current queue
         // to it.
         //
+        this.inFlight++;
         this.socket.write(this.queue.join(''), 'utf8', onError);
 
         this.emit('logged');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant