From ea97826cccaa5f076054f8c40479afa725b2c165 Mon Sep 17 00:00:00 2001 From: David Edler Date: Sun, 2 Feb 2025 14:06:36 +0100 Subject: [PATCH] fix(instance) avoid memory leak on uploading external files. fixes #1087 Signed-off-by: David Edler --- src/util/uploadExternalFormatFile.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/util/uploadExternalFormatFile.tsx b/src/util/uploadExternalFormatFile.tsx index f5109c0e88..8621ac4b39 100644 --- a/src/util/uploadExternalFormatFile.tsx +++ b/src/util/uploadExternalFormatFile.tsx @@ -117,7 +117,10 @@ export const sendFileByWebSocket = ( onProgress(sentFileSize, file.size); } - readNextFileChunk(); + // setTimeout is used to prevent the stack from increasing and + // causing a memory leak on larger files, + // because readNextFileChunk is called recursively + setTimeout(readNextFileChunk, 0); }; reader.onerror = (e) => {