Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Handle connection errors gracefully.

Hand an error to the callback instead of crashing the process
because no event handler is registered for the "error" event.

Closes #137.
  • Loading branch information...
commit 0e6b381e4e8bf3f28618c0db8db84bcd7c7b5a9d 1 parent d79930e
@roidrage roidrage authored
Showing with 18 additions and 1 deletion.
  1. +1 −1  lib/http-request.js
  2. +17 −0 test/http-connection-test.js
View
2  lib/http-request.js
@@ -121,7 +121,7 @@ HttpRequest.prototype.execute = function() {
request.on('error', function(err) {
self.client.emit('riak.request.error', self.event)
- self.client.emit('error', err);
+ callback(err);
});
// write stream
View
17 test/http-connection-test.js
@@ -0,0 +1,17 @@
+var HttpClient = require('../lib/http-client'),
+ HttpMeta = require('../lib/http-meta'),
+ seq = require('seq'),
+ util = require('util'),
+ assert = require('assert'),
+ test = require('../lib/utils').test;
+
+var db = new HttpClient({ port: 64208 });
+
+seq().
+ seq(function() {
+ test("Connection to an unavailable port shouldn't fail the process");
+ db.get('users', 'test', function(err) {
+ assert.ok(err);
+ this.ok();
+ }.bind(this));
+ });
Please sign in to comment.
Something went wrong with that request. Please try again.