winston-syslog: Error: send 111
I’m getting an obscure “send 111” error when trying to log using the unix
protocol. Any ideas? The node-syslog
package works fine, as does using logger
at the command line.
var winston = require('winston');
require('winston-syslog').Syslog;
winston.add(winston.transports.Syslog, {protocol:'unix',path:'/dev/log'});
winston.debug('hi')
debug: hi
Error: send 111
at errnoException (/home/gwarner/winston-syslog/node_modules/unix-dgram/src/unix_dgram.js:25:11)
at Socket.send (/home/gwarner/winston-syslog/node_modules/unix-dgram/src/unix_dgram.js:75:24)
at /home/gwarner/winston-syslog/lib/winston-syslog.js:158:21
at [object Object].Syslog.connect (/home/gwarner/winston-syslog/lib/winston-syslog.js:200:9)
at [object Object].Syslog.log (/home/gwarner/winston-syslog/lib/winston-syslog.js:131:8)
at [object Object].Logger.log (/home/gwarner/winston-syslog/node_modules/winston/lib/winston/logger.js:182:17)
at Object.winston.(anonymous function) [as log] (/home/gwarner/winston-syslog/node_modules/winston/lib/winston.js:82:34)
at Object.target.(anonymous function) [as debug] (/home/gwarner/winston-syslog/node_modules/winston/lib/winston/common.js:44:21)
at repl:1:13
at REPLServer.replDefaults.eval (/usr/lib/node_modules/coffee-script/lib/coffee-script/repl.js:33:42)
at repl.js:239:12
at Interface.<anonymous> (/usr/lib/node_modules/coffee-script/lib/coffee-script/repl.js:64:9)
at Interface.emit (events.js:117:20)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.emit (events.js:117:20)
at emitKey (readline.js:1095:12)
at ReadStream.onData (readline.js:840:14)
at ReadStream.emit (events.js:95:17)
at ReadStream.<anonymous> (_stream_readable.js:748:14)
at ReadStream.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:410:10)
at emitReadable (_stream_readable.js:406:5)
at readableAddChunk (_stream_readable.js:168:9)
at ReadStream.Readable.push (_stream_readable.js:130:10)
at TTY.onread (net.js:528:21)
About this issue
- Original URL
- State: open
- Created 10 years ago
- Comments: 19 (9 by maintainers)
Commits related to this issue
- Fix uncaught errors using unix protocol As suggested by winstonjs/winston-syslog#19 — committed to faust64/winston-syslog by faust64 8 years ago
- Fix uncaught errors using unix protocol As suggested by winstonjs/winston-syslog#19 — committed to faust64/winston-syslog by faust64 8 years ago
I’ve found the same issue, for a different error, related when method connect is called.
unix-dgram code of connect():
code:
when protocol is equal ‘unix’, the socket is created without events handlers attached, so, all errors events from socket is throw as an Unhandled ‘error’ event. But when protocol is defined as unix-dgram, a call to ._unixDgramConnect() is made, so events handlers is attached to the socket created.
Re: https://github.com/winstonjs/winston-syslog/issues/19#issuecomment-1137377288, I didn’t look into how winston-syslog uses unix-dgram but after a “congestion” event you should pause until the next “writable” event.
“congestion” is only emitted for connected sockets. For unconnected sockets you should just back off a bit and retry.
It sounds like there’s a bug in winston-syslog because that -9 error code is EBADF (bad file descriptor) and suggests it closed the socket while still using it.
Thanks for looking into this!
I don’t completely agree, and have spent much of the past couple days on a problem with a non-Winston logger that is not logging everything it needs to, where the expected behavior is very much to bubble that error up, in this case all the way to a human user, to communicate that the content they think should’ve been logged wasn’t logged successfully and a backup strategy should be invoked.
However, I agree that if an app developer expects that behavior, they should be able to configure the logging library to behave that way, and the method of doing so should be well-documented. (I just don’t think it should be the default, especially if it isn’t currently.)
I don’t currently have the expertise and familiarity with unix-dgram (or even the relevant portions of winston-syslog) to go in and more deeply understand that interaction to get it working more smoothly, nor any funding to prioritize gaining that familiarity. However, I agree it does look like there’s an issue here which could get fixed by someone with the appropriate expertise & motivation.
I’m also observing the “Error: send -11” variant of this bug as mentioned in https://github.com/winstonjs/winston-syslog/issues/19#issuecomment-218474530
I’m using version 2.4.4 of winston-syslog.
Error -11 is EAGAIN, which means that some kind of throttling is going on. Regardless of the root cause, such an error should not propagate to the program that does logging.
I am using protocol “unix” so the referenced PR seems not to have caused an effect.