couch-client
couch-client copied to clipboard
Server crashing when receiving a connection refused error message from Couchdb
When calling the "get" message with (id, callback), and attempting to connect on a closed port or to a server which is down (and refusing connections), looks like the error message is improperly handled causing the app server to crash with the following output:
node.js:116 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: ECONNREFUSED, Connection refused at Client._onConnect (net.js:576:18) at IOWatcher.onWritable as callback
This may be a nodejs issue? Currently running with nodejs 4.1.
Similar thing here while getting a 500 http response code from couchdb, resulting expected in no body data.
This stub around line 80 in couch-client.js crashes the node server: response.on('end', function () { 80: if (callback) { callback(null, JSON.parse(body)); } if (stream) { stream.emit('end'); } });
Error trace looks like:
SyntaxError: Unexpected end of input
at Object.parse (native)
at IncomingMessage.