Skip to content

Commit

Permalink
[fix] Fix undeterministic error in polling buffer processing (#529)
Browse files Browse the repository at this point in the history
Ensure all assignments for chunks are Buffer when they should, even when onData is supposed to not
be called again.
  • Loading branch information
raulmt authored and darrachequesne committed Sep 1, 2017
1 parent 3dcc2d5 commit 7f63d38
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/transports/polling.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,10 @@ Polling.prototype.onDataRequest = function (req, res) {
var self = this;

function cleanup () {
chunks = isBinary ? new Buffer(0) : '';
req.removeListener('data', onData);
req.removeListener('end', onEnd);
req.removeListener('close', onClose);
self.dataReq = self.dataRes = null;
self.dataReq = self.dataRes = chunks = null;
}

function onClose () {
Expand All @@ -163,7 +162,7 @@ Polling.prototype.onDataRequest = function (req, res) {
}

if (contentLength > self.maxHttpBufferSize) {
chunks = '';
chunks = isBinary ? new Buffer(0) : '';
req.connection.destroy();
}
}
Expand Down

0 comments on commit 7f63d38

Please sign in to comment.