node.jselasticsearch

What's "EIO: i/o error, write" in node.js and how do I eliminate it?


I have a node.js app using elasticsearch to gather error data and notify relevant stack holders. It starts to give me errors lately (no change has made to the code):

write EIO
Error: write EIO
    at afterWriteDispatched (internal/stream_base_commons.js:154:25)
    at writeGeneric (internal/stream_base_commons.js:145:3)
    at WriteStream.Socket._writeGeneric (net.js:783:11)
    at WriteStream.Socket._write (net.js:795:8)
    at doWrite (_stream_writable.js:385:12)
    at writeOrBuffer (_stream_writable.js:367:5)
    at WriteStream.Writable.write (_stream_writable.js:307:12)
    at Stdio.write (/project/node_modules/elasticsearch/src/lib/loggers/stdio.js:58:6)
    at Stdio.onError (/project/node_modules/elasticsearch/src/lib/loggers/stdio.js:70:8)
    at Log.wrapper (/project/node_modules/lodash/lodash.js:4929:19)
    at Log.emit (events.js:315:20)
    at Log.error (/project/node_modules/elasticsearch/src/lib/log.js:239:17)
    at checkRespForFailure (/project/node_modules/elasticsearch/src/lib/transport.js:298:18)
    at HttpConnector.<anonymous> (/project/node_modules/elasticsearch/src/lib/connectors/http.js:171:7)
    at ClientRequest.wrapper (/project/node_modules/lodash/lodash.js:4929:19)
    at ClientRequest.emit (events.js:315:20)

I suspect this has to do with some type of I/O error on the disk. What can I do to eliminate the error? I am using Node.js v14.0.0 and elasticsearch (npm package) 16.7.1.


Solution

  • This turns out to be a bug in ElasticSearch's log feature due to the fact it is writing to the stdio synchronously. We will either have to turn off the log or use a third party logger.