From 342bbd58cfd6dc241d498d03f8f90afb6b53041d Mon Sep 17 00:00:00 2001 From: Timur Shemsedinov Date: Sun, 15 Mar 2020 02:40:17 +0200 Subject: [PATCH] Improve deadlock behaviour PR-URL: https://github.com/metarhia/web-locks/pull/18 --- web-locks.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web-locks.js b/web-locks.js index b810bc7..ae40d86 100644 --- a/web-locks.js +++ b/web-locks.js @@ -26,7 +26,9 @@ class Lock { return new Promise(resolve => { this.queue.push({ handler, resolve }); this.trying = true; - this.tryEnter(); + setTimeout(() => { + this.tryEnter(); + }, 0); }); }