feat: bufferedAmount flow control in WS upload, bump 1.0.16
Deploy loadtest / validate (push) Waiting to run
Deploy loadtest / validate (push) Waiting to run
This commit is contained in:
+11
-2
@@ -210,8 +210,13 @@ function uploadFileWS(url, f, idx) {
|
||||
|
||||
ws.onopen = function () {
|
||||
var reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
ws.send(e.target.result);
|
||||
|
||||
function sendOrWait(data) {
|
||||
if (ws.bufferedAmount > 256 * 1024) {
|
||||
setTimeout(function () { sendOrWait(data); }, 10);
|
||||
return;
|
||||
}
|
||||
ws.send(data);
|
||||
offset += CHUNK;
|
||||
if (offset < f.size) {
|
||||
var pct = Math.round(offset / f.size * 100);
|
||||
@@ -224,6 +229,10 @@ function uploadFileWS(url, f, idx) {
|
||||
} else {
|
||||
ws.send('DONE');
|
||||
}
|
||||
}
|
||||
|
||||
reader.onload = function (e) {
|
||||
sendOrWait(e.target.result);
|
||||
};
|
||||
function readNext() {
|
||||
var end = Math.min(offset + CHUNK, f.size);
|
||||
|
||||
Reference in New Issue
Block a user