From cfe5b4afda482c11e88e06afad0e5ede3550d029 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Mon, 5 Feb 2024 04:03:12 +0100 Subject: [PATCH] Prevent full datachannel buffer on file end --- public/scripts/network.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/scripts/network.js b/public/scripts/network.js index ce7195a..2e10fc0 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -1564,7 +1564,7 @@ class FileChunker { } _readChunk() { - if (this._currentlySending) return; + if (this._currentlySending || this._isFileEnd()) return; this._currentlySending = true; const chunk = this._file.slice(this._bytesSent, this._bytesSent + this._chunkSize); @@ -1606,6 +1606,8 @@ class FileChunkerRTC extends FileChunker { } _onChunkRead(chunk) { + if (!chunk.byteLength) return; + this._currentlySending = false; this._onChunk(chunk);