Skip to content

Fake timers created inside coroutines which are then closed by coroutine.close/task.cancel still attempt to resume #18

Description

@nomer888

This code causes the test to error with 'cannot spawn non-suspended coroutine with arguments', despite being valid when using real timers:

it("timer resume bug", function()
	jest.useFakeTimers()

	local thread
	task.spawn(function()
		task.wait()
		coroutine.close(thread)
	end)
	thread = task.spawn(function()
		task.wait()
		-- no code should execute as this point, and there shouldn't be any errors
	end)

	jest.runAllTimers()
end)

If coroutine.close is swapped with task.cancel, any code after the task.wait() in the thread will still execute, whereas with real timers it won't.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions