node.jsjenkinsstubbydb

nodejs error on logging to console


I have created a plugin stubbydb that is running fine on local machine. But while running on a remote server using jenkins, I am getting following error.

2016-03-16T10:58:10.745Z - error: uncaughtException: write EPIPE date=Wed Mar 16 2016 10:58:10 GMT+0000 (GMT), pid=23729, uid=501, gid=500, cwd=/home/deployment, execPath=/usr/local/node/node-v5.2.0/bin/node, version=v5.2.0, argv=[/usr/local/node/node-v5.2.0/bin/node, /usr/local/node/node-default/bin/stubbydb, -d, /tmp/soa-simulator, -p, 7777, -s, /tmp/soa-simulator/], rss=22597632, heapTotal=12671264, heapUsed=8094384, loadavg=[1.7158203125, 0.68505859375, 0.27392578125], uptime=5615485, trace=[column=11, file=util.js, function=Object.exports._errnoException, line=856, method=exports._errnoException, native=false, column=20, file=util.js, function=exports._exceptionWithHostPort, line=879, method=_exceptionWithHostPort, native=false, column=14, file=net.js, function=WriteWrap.afterWrite, line=764, method=afterWrite, native=false], stack=[Error: write EPIPE,     at Object.exports._errnoException (util.js:856:11),     at exports._exceptionWithHostPort (util.js:879:20),     at WriteWrap.afterWrite (net.js:764:14)]

2016-03-16T10:58:36.696Z - error: uncaughtException: This socket is closed. date=Wed Mar 16 2016 10:58:36 GMT+0000 (GMT), pid=23729, uid=501, gid=500, cwd=/home/deployment, execPath=/usr/local/node/node-v5.2.0/bin/node, version=v5.2.0, argv=[/usr/local/node/node-v5.2.0/bin/node, /usr/local/node/node-default/bin/stubbydb, -d, /tmp/soa-simulator, -p, 7777, -s, /tmp/soa-simulator/], rss=25243648, heapTotal=12671264, heapUsed=8775480, loadavg=[1.443359375, 0.7080078125, 0.291015625], uptime=5615511, trace=[column=19, file=net.js, function=Socket._writeGeneric, line=641, method=_writeGeneric, native=false, column=8, file=net.js, function=Socket._write, line=695, method=_write, native=false, column=12, file=_stream_writable.js, function=doWrite, line=293, method=null, native=false, column=5, file=_stream_writable.js, function=writeOrBuffer, line=279, method=null, native=false, column=11, file=_stream_writable.js, function=Socket.Writable.write, line=208, method=Writable.write, native=false, column=40, file=net.js, function=Socket.write, line=619, method=write, native=false, column=16, file=console.js, function=Console.log, line=37, method=log, native=false, column=12, file=/usr/local/node/node-v5.2.0/lib/node_modules/stubby-db/js/stubbyDB.js, function=, line=29, method=null, native=false, column=13, file=events.js, function=emitNone, line=68, method=null, native=false, column=7, file=events.js, function=IncomingMessage.emit, line=167, method=emit, native=false], stack=[Error: This socket is closed.,     at Socket._writeGeneric (net.js:641:19),     at Socket._write (net.js:695:8),     at doWrite (_stream_writable.js:293:12),     at writeOrBuffer (_stream_writable.js:279:5),     at Socket.Writable.write (_stream_writable.js:208:11),     at Socket.write (net.js:619:40),     at Console.log (console.js:37:16),     at IncomingMessage.<anonymous> (/usr/local/node/node-v5.2.0/lib/node_modules/stubby-db/js/stubbyDB.js:29:12),     at emitNone (events.js:68:13),     at IncomingMessage.emit (events.js:167:7)]

So till the time jenkins job is running stubbydb responses. But as soon as jenkins job is completed. It stopped working. And Gives error on console.log() statement.

If I login to the server and do console.log("something") on node console. I see no error. Moreover, if I run stubbydb directly there after login instead of jenkins. It works fine.

What can be the reason? Should I avoid writing to console?


Solution

  • I couldn't find anything wrong with the application. The problem is automatically solved. It seems to be with jenkins job or server setup. However I have removed all default console.log and made logging on demand. So if anyone face the same issue, just switch off the logging.