Skip to content

Commit

Permalink
Revert "[front] Handle backpressure manually to avoid getting stuck (#…
Browse files Browse the repository at this point in the history
…9575)"

This reverts commit ef479bb.
  • Loading branch information
tdraier authored Jan 8, 2025
1 parent efab9df commit ca8f12c
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions front/lib/api/files/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>((resolve, reject) => {
writeStream.on("finish", resolve);
writeStream.on("error", reject);
});
await pipeline(processedStream, writeStream);

return new Ok(undefined);
} catch (err) {
Expand Down

0 comments on commit ca8f12c

Please sign in to comment.