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

Winston crashes process (solved) & does NOT reconnect to Papertrail after LOST connection (open) #90

Open
thebarty opened this issue Oct 14, 2019 · 5 comments

Comments

@thebarty
Copy link

thebarty commented Oct 14, 2019

Hi guys,

woohhhaaa! my winston setup crashes the process when the connection to papertrail is lost:

    "winston": "^3.2.1",
    "winston-papertrail": "^1.0.5"
        const papertrailLogger = new winston.transports.Papertrail({
            // for options see https://github.com/kenperkins/winston-papertrail
            host,
            port,
            level: 'info',
            logFormat(level, message) {
                return `[${level}] ${message}`
            },
            inlineMeta: true,  // attach meta data inline (TODO switch it off completely see https://github.com/kenperkins/winston-papertrail/issues/85)
        })
        papertrailLogger.on('error', (err) => {
            // Handle, report, or silently ignore connection errors and failures
            console.error('[Log] papertrailLogger.error', err)
        })
        transports.push(papertrailLogger)
ERROR:
{ Error: write EADDRNOTAVAIL
W20191014-09:57:04.888(2)? (STDERR)     at _errnoException (util.js:992:11)
W20191014-09:57:04.888(2)? (STDERR)     at WriteWrap.afterWrite (net.js:864:14)
W20191014-09:57:04.888(2)? (STDERR)   code: 'EADDRNOTAVAIL',
W20191014-09:57:04.888(2)? (STDERR)   errno: 'EADDRNOTAVAIL',
W20191014-09:57:04.889(2)? (STDERR)   syscall: 'write' }
W20191014-09:57:04.889(2)? (STDERR) events.js:183
W20191014-09:57:04.889(2)? (STDERR)       throw er; // Unhandled 'error' event
W20191014-09:57:04.889(2)? (STDERR)       ^
W20191014-09:57:04.890(2)? (STDERR) 

and

W20191014-09:57:10.430(2)? (STDERR) [Log] papertrailLogger.error { Error: getaddrinfo ENOTFOUND logsXXXX.papertrailapp.com logsXXXX.papertrailapp.com:123124
W20191014-09:57:10.430(2)? (STDERR)     at errnoException (dns.js:50:10)
W20191014-09:57:10.430(2)? (STDERR)     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)
W20191014-09:57:10.431(2)? (STDERR)   code: 'ENOTFOUND',
W20191014-09:57:10.431(2)? (STDERR)   errno: 'ENOTFOUND',
W20191014-09:57:10.431(2)? (STDERR)   syscall: 'getaddrinfo',
W20191014-09:57:10.431(2)? (STDERR)   hostname: 'logsXXXX.papertrailapp.com',
W20191014-09:57:10.431(2)? (STDERR)   host: 'logsXXXX.papertrailapp.com',
W20191014-09:57:10.431(2)? (STDERR)   port: 123124 }
W20191014-09:57:10.431(2)? (STDERR) events.js:183
W20191014-09:57:10.432(2)? (STDERR)       throw er; // Unhandled 'error' event
W20191014-09:57:10.432(2)? (STDERR)       ^
W20191014-09:57:10.432(2)? (STDERR) 
W20191014-09:57:10.432(2)? (STDERR) Error: getaddrinfo ENOTFOUND logsXXXX.papertrailapp.com logsXXXX.papertrailapp.com:123124
W20191014-09:57:10.432(2)? (STDERR)     at errnoException (dns.js:50:10)
W20191014-09:57:10.432(2)? (STDERR)     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:92:26)

I wouldn't expect a pro-logger library to need a try-catch.

Is this package still maintained?

@thebarty
Copy link
Author

Ok I have found a solution to prevent crashes:

add this line to your config

            handleExceptions: true,  // see https://github.com/winstonjs/winston#exceptions

like

        const papertrailLogger = new winston.transports.Papertrail({
            // for options see https://github.com/kenperkins/winston-papertrail
            host,
            port,
            level: 'info',
            logFormat(level, message) {
                return `[${level}] ${message}`
            },
            inlineMeta: true,  // attach meta data inline (TODO switch it off completely see https://github.com/kenperkins/winston-papertrail/issues/85)
            handleExceptions: true,  // see https://github.com/winstonjs/winston#exceptions
        })

@thebarty
Copy link
Author

I can provoke this locally by switching off WLAN.

The remaining problem is that AFTER LOOSING the connection once, it does NOT reconnect to papertrail.

Any idea how to have winston RECONNECT to papertrail?

@thebarty thebarty changed the title Winston crashes process Winston crashes process (solved) & does NOT reconnect to Papertrail after LOST connection (open) Oct 14, 2019
@kdolan
Copy link

kdolan commented Oct 25, 2019

I have same issue with no ability to reconnect. I have had that issue for a while now, it's rather annoying. If anybody has a fix for this it would be much appreciated.

@paulhklam1122
Copy link

Yes, having trouble with this issue too. We're trying to use this in an electron app context.

@kylebuildsstuff
Copy link

kylebuildsstuff commented Oct 11, 2021

Been having the same issue for a while too, and switching to the syslog transport, or adding handleExceptions to the transport and logger doesn't prevent the crash for my apps. I've been thinking of switching to http logs but I don't know if it's going to have the same problem too or if it's just going to be much slower.

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

4 participants