Server crashing when receiving a connection refused error message from Couchdb #22

Open
aausch opened this Issue Apr 11, 2011 · 1 comment

Projects

None yet

2 participants

@aausch

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.

@aldipower

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment