From a646d6731abce107bb7027d3363f38ef5b89d209 Mon Sep 17 00:00:00 2001 From: Bobby Date: Sat, 24 Sep 2022 06:41:31 +0700 Subject: [PATCH] fix: possible upload stream starting early --- controllers/uploadController.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/controllers/uploadController.js b/controllers/uploadController.js index f45043d..321ad88 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -432,6 +432,8 @@ self.actuallyUpload = async (req, res, data = {}) => { if (hashStream) { hashStream.once('error', _reject) + // Ensure readStream will only be resumed later down the line by readStream.pipe() + readStream.pause() readStream.on('data', data => { // .dispose() will destroy this internal component, // so use it as an indicator of whether the hashStream has been .dispose()'d