couch-client icon indicating copy to clipboard operation
couch-client copied to clipboard

Server crashing when receiving a connection refused error message from Couchdb

Open aausch opened this issue 13 years ago • 1 comments

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.

aausch avatar Apr 11 '11 20:04 aausch

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. (.../node_modules/couch-client/lib/couch-client.js:80:45) at IncomingMessage.emit (events.js:81:20) at HTTPParser.onMessageComplete (http.js:133:23) at Socket.ondata (http.js:1226:22) at Socket._onReadable (net.js:683:27) at IOWatcher.onReadable as callback

aldipower avatar Jun 21 '11 21:06 aldipower