From 3a96a1d2a770e6e64c31f4a355d28595b0ae33c0 Mon Sep 17 00:00:00 2001 From: Niles Date: Sat, 22 Aug 2020 03:49:59 -0500 Subject: [PATCH] Allow OnCancel to break out of the current loop --- lib/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/init.lua b/lib/init.lua index b5d71db..07781a7 100644 --- a/lib/init.lua +++ b/lib/init.lua @@ -715,7 +715,9 @@ do if connection == nil then -- first is nil when connection is nil first = node connection = Promise._timeEvent:Connect(function() - while first.endTime <= Promise._getTime() do + local threadStart = Promise._getTime() + + while first ~= nil and first.endTime < threadStart do local current = first first = current.next @@ -727,7 +729,6 @@ do end current.resolve(Promise._getTime() - current.startTime) - if current.next == nil then return end -- kill this thread if there was no `first` before `resolve` end end) else -- first is non-nil