diff --git a/src/Utils/make-mutex.ts b/src/Utils/make-mutex.ts index d897903..b02878f 100644 --- a/src/Utils/make-mutex.ts +++ b/src/Utils/make-mutex.ts @@ -9,8 +9,13 @@ export const makeMutex = () => { await task } catch{ } - // execute the current task - return code() + try { + // execute the current task + const result = await code() + return result + } finally { + clearTimeout(taskTimeout) + } })() // we replace the existing task, appending the new piece of execution to it // so the next task will have to wait for this one to finish diff --git a/yarn.lock b/yarn.lock index 1228770..0e4fb44 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3480,9 +3480,9 @@ json-stable-stringify-without-jsonify@^1.0.1: integrity sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE= json5@2.x, json5@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.1.tgz#655d50ed1e6f95ad1a3caababd2b0efda10b395c" - integrity sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA== + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== jsonc-parser@^3.0.0: version "3.0.0"