Skip to content

Commit ffb4c0b

Browse files
committed
Let fake WebSocket handle large sends
Dynamically grow the recorded send buffer if the test needs to send a lot of data.
1 parent a446551 commit ffb4c0b

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

tests/fake.websocket.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ export default class FakeWebSocket {
3737
} else {
3838
data = new Uint8Array(data);
3939
}
40+
if (this.bufferedAmount + data.length > this._sendQueue.length) {
41+
let newlen = this._sendQueue.length;
42+
while (this.bufferedAmount + data.length > newlen) {
43+
newlen *= 2;
44+
}
45+
let newbuf = new Uint8Array(newlen);
46+
newbuf.set(this._sendQueue);
47+
this._sendQueue = newbuf;
48+
}
4049
this._sendQueue.set(data, this.bufferedAmount);
4150
this.bufferedAmount += data.length;
4251
}

0 commit comments

Comments
 (0)