feat: bufferedAmount flow control in WS upload, bump 1.0.16
Deploy loadtest / validate (push) Waiting to run

This commit is contained in:
2026-07-11 06:38:38 +04:00
parent a851bfb102
commit b509491c60
3 changed files with 102 additions and 3 deletions
+11 -2
View File
@@ -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);