Skip to content

Commit

Permalink
[fix] Use workaround for setEncoding bug in node 0.10+ (#527)
Browse files Browse the repository at this point in the history
The server often crashes with 'TypeError: "list" argument must be an Array of Buffers' errors,
which is caused by a bug in new versions of node, where setEncoding call does not work for messages
that are already in the queue.

This pull request makes sure that concat is never called in the non binary case, even if
setEncoding does not work properly.
  • Loading branch information
nightwing authored and darrachequesne committed Aug 31, 2017
1 parent e76e035 commit 3dcc2d5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/transports/polling.js
Expand Up @@ -154,12 +154,12 @@ Polling.prototype.onDataRequest = function (req, res) {

function onData (data) {
var contentLength;
if (typeof data === 'string') {
chunks += data;
contentLength = Buffer.byteLength(chunks);
} else {
if (isBinary) {
chunks = Buffer.concat([chunks, data]);
contentLength = chunks.length;
} else {
chunks += data;
contentLength = Buffer.byteLength(chunks);
}

if (contentLength > self.maxHttpBufferSize) {
Expand Down

0 comments on commit 3dcc2d5

Please sign in to comment.