From a59ee9a30792b8d5bb5e42b481c18f6222a67577 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 15 Sep 2015 09:23:55 -0700 Subject: [PATCH] Fixed a couple of incorrect "this" references in Node library --- src/node/src/server.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/node/src/server.js b/src/node/src/server.js index b6f162adf85..70b4a9d80e3 100644 --- a/src/node/src/server.js +++ b/src/node/src/server.js @@ -276,6 +276,7 @@ function ServerWritableStream(call, serialize) { function _write(chunk, encoding, callback) { /* jshint validthis: true */ var batch = {}; + var self = this; if (!this.call.metadataSent) { batch[grpc.opType.SEND_INITIAL_METADATA] = (new Metadata())._getCoreRepresentation(); @@ -290,7 +291,7 @@ function _write(chunk, encoding, callback) { batch[grpc.opType.SEND_MESSAGE] = message; this.call.startBatch(batch, function(err, value) { if (err) { - this.emit('error', err); + self.emit('error', err); return; } callback(); @@ -305,6 +306,7 @@ ServerWritableStream.prototype._write = _write; */ function sendMetadata(responseMetadata) { /* jshint validthis: true */ + var self = this; if (!this.call.metadataSent) { this.call.metadataSent = true; var batch = []; @@ -312,7 +314,7 @@ function sendMetadata(responseMetadata) { responseMetadata._getCoreRepresentation(); this.call.startBatch(batch, function(err) { if (err) { - this.emit('error', err); + self.emit('error', err); return; } });