From ca8f12ce2885c150fc1470bf5372b72d7fb6a13c Mon Sep 17 00:00:00 2001 From: Thomas Draier Date: Wed, 8 Jan 2025 11:19:05 +0100 Subject: [PATCH] Revert "[front] Handle backpressure manually to avoid getting stuck (#9575)" This reverts commit ef479bbd6e78c24d18db3dd3c15ccb1e3775a2ce. --- front/lib/api/files/upload.ts | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/front/lib/api/files/upload.ts b/front/lib/api/files/upload.ts index 298f2439bd23..54cbd264a1ef 100644 --- a/front/lib/api/files/upload.ts +++ b/front/lib/api/files/upload.ts @@ -133,32 +133,7 @@ const extractTextFromFileAndUpload: ProcessingFunction = async ( config.getTextExtractionUrl() ).fromStream(readStream, file.contentType); - processedStream.on("data", (chunk) => { - // Handle backpressure - const canWrite = writeStream.write(chunk); - if (!canWrite) { - readStream.pause(); - writeStream.once("drain", () => readStream.resume()); - } - }); - - processedStream.on("end", () => { - writeStream.end(); - }); - - processedStream.on("error", (err) => { - throw err; - }); - - writeStream.on("error", (err) => { - throw err; - }); - - // Await the completion of the writeStream - await new Promise((resolve, reject) => { - writeStream.on("finish", resolve); - writeStream.on("error", reject); - }); + await pipeline(processedStream, writeStream); return new Ok(undefined); } catch (err) {