Skip to content

Commit 3dcc2d5

Browse files
nightwingdarrachequesne
authored andcommittedAug 31, 2017
[fix] Use workaround for setEncoding bug in node 0.10+ (#527)
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.
1 parent e76e035 commit 3dcc2d5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎lib/transports/polling.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ Polling.prototype.onDataRequest = function (req, res) {
154154

155155
function onData (data) {
156156
var contentLength;
157-
if (typeof data === 'string') {
158-
chunks += data;
159-
contentLength = Buffer.byteLength(chunks);
160-
} else {
157+
if (isBinary) {
161158
chunks = Buffer.concat([chunks, data]);
162159
contentLength = chunks.length;
160+
} else {
161+
chunks += data;
162+
contentLength = Buffer.byteLength(chunks);
163163
}
164164

165165
if (contentLength > self.maxHttpBufferSize) {

0 commit comments

Comments
 (0)
Please sign in to comment.