Cannot resume dead coroutine

Recently I started getting the cannot resume dead coroutine error. It doesn’t seem to influence my code, but it’s very annoying. There’s an existing post with some other people mentioning this issue, but it doesn’t look like it got much traction: Cannot resume dead coroutine despite it being a new coroutine

In my case, here’s the code that triggers this error:

local jumpPromise = Promise.new(function(resolve)
	repeat
		local _, new = self.humanoid.StateChanged:Wait()
	until new == Enum.HumanoidStateType.Jumping

	resolve()
end)

local finishPromise = Promise.new(function(resolve)
	task.wait(0.1)
	resolve()
end)

local statePromise = Promise.any({jumpPromise, finishPromise}):andThen(function()
	self:evaluate()
end)

I tried to get a minimal repro working, but I couldn’t manage to do that.
This error appears both in studio and in-game

Expected behavior

The error should be gone. Not sure what effect it has since my code still seems to function correctly.

A private message is associated with this bug report

4 Likes

put it in a pcall to remove error

1 Like

I made this feature request a long time ago for this issue to be fixed:

Canceling Coroutines Still Needs Work - Feature Requests / Engine Features - Developer Forum | Roblox


The error shows when the engine resumes the coroutine which is already in a dead state. For example:

local Thread = task.spawn(function()
      workspace.ChildAdded:Wait()
end)

task.cancel(Thread)
Instance.new("Part", workspace) --> This will trigger the event which will then attempt to resume the coroutine that was canceled already.

This is how big of an issue it is:

1 Like

closing in favor of Canceling Coroutines Still Needs Work - Feature Requests / Engine Features - Developer Forum | Roblox