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

Causes thrown error when log is written before TCP connects #103

Open
knightcode opened this issue Jun 13, 2018 · 3 comments
Open

Causes thrown error when log is written before TCP connects #103

knightcode opened this issue Jun 13, 2018 · 3 comments

Comments

@knightcode
Copy link

If the logger is written to before a TCP connection is established, the following code executes to properly queue the log message, but then it passes err to the log's callback, which produces the error below for me.

Someone would know better than, but it seems like if you're queuing the message, it's mildly acceptable to pass a success condition to callback.

winston-syslog.js, line 129

    this.connect((err) => {
      if (err) {
        //
        // If there was an error enqueue the message
        //
        this.queue.push(syslogMsg);

        return callback(err);  <------- 'err' bubbles up to logger
      }
Error: Unhandled "error" event. (true)
    at DerivedLogger.emit (events.js:186:19)
    at DerivedLogger.transportError (/docs/savory/savorycatering/node_modules/winston/lib/winston/logger.js:504:12)
    at emitOne (events.js:121:20)
    at Syslog.emit (events.js:211:7)
    at onwriteError (_stream_writable.js:412:12)
    at onwrite (_stream_writable.js:440:5)
    at connect (/docs/savory/savorycatering/node_modules/winston-syslog/lib/winston-syslog.js:138:16)
    at Syslog.connect (/docs/savory/savorycatering/node_modules/winston-syslog/lib/winston-syslog.js:272:5)
    at Syslog.log (/docs/savory/savorycatering/node_modules/winston-syslog/lib/winston-syslog.js:130:10)
    at Syslog.TransportStream._write (/docs/savory/savorycatering/node_modules/winston-transport/index.js:88:17)
    at doWrite (_stream_writable.js:397:12)
    at writeOrBuffer (_stream_writable.js:383:5)
    at Syslog.Writable.write (_stream_writable.js:290:11)
    at DerivedLogger.ondata (/docs/savory/savorycatering/node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js:619:20)
    at emitOne (events.js:116:13)
    at DerivedLogger.emit (events.js:211:7)
    at addChunk (/docs/savory/savorycatering/node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js:291:12)
    at readableAddChunk (/docs/savory/savorycatering/node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js:278:11)
    at DerivedLogger.Readable.push (/docs/savory/savorycatering/node_modules/winston/node_modules/readable-stream/lib/_stream_readable.js:245:10)
    at DerivedLogger.Transform.push (/docs/savory/savorycatering/node_modules/winston/node_modules/readable-stream/lib/_stream_transform.js:148:32)
    at DerivedLogger._transform (/docs/savory/savorycatering/node_modules/winston/lib/winston/logger.js:210:12)
    at DerivedLogger.Transform._read (/docs/savory/savorycatering/node_modules/winston/node_modules/readable-stream/lib/_stream_transform.js:184:10)
@Esya
Copy link

Esya commented Jul 6, 2018

Same for us, does anyone have a solution for this? This causes an unhandled exception and crashes our app

@knightcode
Copy link
Author

I forked the repo and made changes to fix this and the other issue I posted here: https://github.com/Savorylabs/winston-syslog

The simple fix is only for those who can tolerate lack of feedback.

While this repo is dormant, you can add this to your package.json to get fetch it:

    "winston-syslog": "https://github.com/Savorylabs/winston-syslog/archive/2.0.1.tar.gz",

@massimopibiri
Copy link

I forked the repo and made changes to fix this and the other issue I posted here: https://github.com/Savorylabs/winston-syslog

The simple fix is only for those who can tolerate lack of feedback.

While this repo is dormant, you can add this to your package.json to get fetch it:

    "winston-syslog": "https://github.com/Savorylabs/winston-syslog/archive/2.0.1.tar.gz",

Thank you. That's cool!

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

3 participants