Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
Fix TimeoutWarning bug on self call
Browse files Browse the repository at this point in the history
  • Loading branch information
metatablecat committed Jul 23, 2024
1 parent 03bff1b commit 5bfe973
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/Dispatcher.luau
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ local function killThread(t: thread)
local co = coroutine.running()
if co ~= t then
coroutine.close(t)
return false
else
task.defer(coroutine.close, t)
coroutine.yield()
return true
end
end

Expand All @@ -139,10 +140,11 @@ function Dispatcher.stop(o, state)
if not Dispatcher.isSelfAsyncCall(o) then end

-- not destroyed, kill running thread then free as false
killThread(state.Thread)
if state.TimeoutThread then killThread(state.TimeoutThread) end
local isSelfCall = killThread(state.Thread)

free(state, false, "Object has been destroyed before it could return")
if isSelfCall then coroutine.yield() end
end

local function spawnObject(object, service, state, asyncMode)
Expand Down

0 comments on commit 5bfe973

Please sign in to comment.