From cfbef54217d2d8a7cadc2920656d8a3db7925163 Mon Sep 17 00:00:00 2001 From: Andrey Ponomarenko Date: Fri, 25 Sep 2020 22:14:51 +0300 Subject: [PATCH] fix: fix max api status calls increment --- src/core/upload/index.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/upload/index.ts b/src/core/upload/index.ts index fcee732..26697f0 100644 --- a/src/core/upload/index.ts +++ b/src/core/upload/index.ts @@ -27,14 +27,12 @@ export const upload = async (props: ApiUploadProps, options: Options = {}) => { // recursive status checks const checkStatus = async (): Promise => { + if (statusCallsCount > maxApiStatusCalls) throw new Error('max api calls exceeded'); + const jobStatus = await fetchJobStatus({ token, job }); const { status, message } = jobStatus; - if (statusCallsCount > maxApiStatusCalls) { - statusCallsCount += 1; - throw new Error('max api calls exceeded'); - } - + statusCallsCount += 1; onStatusProgress(status); switch (status) {