From 908635a1deb89e11b86d746a297364f313a22618 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 7 Feb 2021 18:57:25 -0500 Subject: [PATCH] ImportHandler: Use `return reject(...)` to avoid double settle --- src/node/handler/ImportHandler.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js index 399192761..a542a6d30 100644 --- a/src/node/handler/ImportHandler.js +++ b/src/node/handler/ImportHandler.js @@ -99,16 +99,15 @@ const doImport = async (req, res, padId) => { // I hate doing indexOf here but I can't see anything to use... if (err && err.stack && err.stack.indexOf('maxFileSize') !== -1) { - reject('maxFileSize'); + return reject('maxFileSize'); } - reject('uploadFailed'); + return reject('uploadFailed'); } if (!files.file) { // might not be a graceful fix but it works - reject('uploadFailed'); - } else { - resolve(files.file.path); + return reject('uploadFailed'); } + resolve(files.file.path); }); }); @@ -177,7 +176,7 @@ const doImport = async (req, res, padId) => { // catch convert errors if (err) { console.warn('Converting Error:', err); - reject('convertFailed'); + return reject('convertFailed'); } resolve(); });