THRIFT-2932: Node.js Thrift connection libraries throw Exceptions into event emitter
Client: Nodejs
Patch: Tom Croucher and Andrew de Andrade
This commits a limited set of hunks from teh original patch.
diff --git a/lib/nodejs/README.md b/lib/nodejs/README.md
index 22c7caa..88499f7 100644
--- a/lib/nodejs/README.md
+++ b/lib/nodejs/README.md
@@ -60,10 +60,6 @@
Since JavaScript represents all numbers as doubles, int64 values cannot be accurately represented naturally. To solve this, int64 values in responses will be wrapped with Thirft.Int64 objects. The Int64 implementation used is [broofa/node-int64](https://github.com/broofa/node-int64).
-## Libraries using node-thrift
+## Client and server examples
-* [yukim/node_cassandra](https://github.com/yukim/node_cassandra)
-
-## Custom client and server example
-
-An example based on the one shown on the Thrift front page is included in the examples/ folder.
+Several example clients and servers are included in the thrift/lib/nodejs/examples folder and the cross language tutorial thrift/tutorial/nodejs folder.
diff --git a/lib/nodejs/lib/thrift/http_connection.js b/lib/nodejs/lib/thrift/http_connection.js
index ced1352..b7659bc 100644
--- a/lib/nodejs/lib/thrift/http_connection.js
+++ b/lib/nodejs/lib/thrift/http_connection.js
@@ -19,7 +19,7 @@
var util = require('util');
var http = require('http');
var https = require('https');
-var EventEmitter = require("events").EventEmitter;
+var EventEmitter = require('events').EventEmitter;
var thrift = require('./thrift');
var ttransport = require('./transport');
var tprotocol = require('./protocol');
@@ -93,8 +93,8 @@
this.nodeOptions[attrname] = this.options.nodeOptions[attrname];
}
/*jshint -W069 */
- if (! this.nodeOptions.headers["Connection"]) {
- this.nodeOptions.headers["Connection"] = "keep-alive";
+ if (! this.nodeOptions.headers['Connection']) {
+ this.nodeOptions.headers['Connection'] = 'keep-alive';
}
/*jshint +W069 */
@@ -132,7 +132,9 @@
var clientCallback = client._reqs[header.rseqid];
delete client._reqs[header.rseqid];
if (clientCallback) {
- clientCallback(err, success);
+ process.nextTick(function() {
+ clientCallback(err, success);
+ });
}
};
/*jshint +W083 */
diff --git a/lib/nodejs/test/thrift_test_driver.js b/lib/nodejs/test/thrift_test_driver.js
index b7312fa..5ddcb21 100644
--- a/lib/nodejs/test/thrift_test_driver.js
+++ b/lib/nodejs/test/thrift_test_driver.js
@@ -171,8 +171,6 @@
assert.equal(7.012052175215044, response);
});
-// TODO: add testBinary()
-
var out = new ttypes.Xtruct({
string_thing: 'Zero',
byte_thing: 1,