From 2fb16aafa3254b42c4d53b60c0782fb627154085 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 22 May 2015 09:49:06 -0700 Subject: [PATCH 1/4] Fixed ordering assumptions in server_streaming interop test --- src/node/interop/interop_client.js | 6 ++++-- src/node/src/client.js | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/node/interop/interop_client.js b/src/node/interop/interop_client.js index 80f811901ca..455055d9f3c 100644 --- a/src/node/interop/interop_client.js +++ b/src/node/interop/interop_client.js @@ -154,13 +154,15 @@ function serverStreaming(client, done) { arg.response_parameters[resp_index].size); resp_index += 1; }); - call.on('status', function(status) { - assert.strictEqual(status.code, grpc.status.OK); + call.on('end', function() { assert.strictEqual(resp_index, 4); if (done) { done(); } }); + call.on('status', function(status) { + assert.strictEqual(status.code, grpc.status.OK); + }); } /** diff --git a/src/node/src/client.js b/src/node/src/client.js index efec05bbf3d..be1e5347072 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -81,7 +81,7 @@ function _write(chunk, encoding, callback) { batch[grpc.opType.SEND_MESSAGE] = this.serialize(chunk); this.call.startBatch(batch, function(err, event) { if (err) { - // Something has gone wrong. Stop writing by failing to call callback + callback(err); return; } callback(); @@ -125,11 +125,9 @@ function _read(size) { self.finished = true; return; } - if (self.finished) { - self.push(null); - return; - } var data = event.read; + var deserialized = self.deserialize(data); + console.log(deserialized); if (self.push(self.deserialize(data)) && data !== null) { var read_batch = {}; read_batch[grpc.opType.RECV_MESSAGE] = true; From fe29b6dea1db08ea4edd1748f29dfc6cd35a33fd Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 22 May 2015 09:50:41 -0700 Subject: [PATCH 2/4] Removed debug log --- src/node/src/client.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/node/src/client.js b/src/node/src/client.js index be1e5347072..c9c0318b6da 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -126,8 +126,6 @@ function _read(size) { return; } var data = event.read; - var deserialized = self.deserialize(data); - console.log(deserialized); if (self.push(self.deserialize(data)) && data !== null) { var read_batch = {}; read_batch[grpc.opType.RECV_MESSAGE] = true; From 6d1a8449d1f485d6d037b397a5df7ac42218c5e9 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 22 May 2015 10:29:05 -0700 Subject: [PATCH 3/4] Coalesced redundant code --- src/node/src/client.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/node/src/client.js b/src/node/src/client.js index c9c0318b6da..9a50bf24d9c 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -80,11 +80,7 @@ function _write(chunk, encoding, callback) { var batch = {}; batch[grpc.opType.SEND_MESSAGE] = this.serialize(chunk); this.call.startBatch(batch, function(err, event) { - if (err) { - callback(err); - return; - } - callback(); + callback(err); }); } From b4f244f0da5c342f6a62db02bf32bb6c4e695d4d Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 22 May 2015 11:06:11 -0700 Subject: [PATCH 4/4] Reverted change to _write in client.js --- src/node/src/client.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/node/src/client.js b/src/node/src/client.js index 9a50bf24d9c..65339406b2c 100644 --- a/src/node/src/client.js +++ b/src/node/src/client.js @@ -80,7 +80,11 @@ function _write(chunk, encoding, callback) { var batch = {}; batch[grpc.opType.SEND_MESSAGE] = this.serialize(chunk); this.call.startBatch(batch, function(err, event) { - callback(err); + if (err) { + // Something has gone wrong. Stop writing by failing to call callback + return; + } + callback(); }); }