Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future.luau - error handling when using coroutine.resume #9

Open
4x8Matrix opened this issue Jan 28, 2025 · 0 comments
Open

Future.luau - error handling when using coroutine.resume #9

4x8Matrix opened this issue Jan 28, 2025 · 0 comments

Comments

@4x8Matrix
Copy link

Currently, the Future library uses the coroutine library to yield and resume threads, however - by doing this you're taking the responsibility of coroutine errors.

I have found that in Future.luau - we are resuming a thread, without validating if it has errored or not. This can lead to silent errors that don't tell the developer what issue they're facing.

I would appreciate if there is some error handling thrown into the Future lib so in the event a coroutine has been resumed errors out, the developer is made aware of it.

an example of where this can be problematic:

local future = require("future")
local task = require("@lune/task")

future.Future
	.new(function()
		task.wait(1)

		return 1
	end)
	:await()
	:unwrapOk()

error(123) -- never prints, this was resumed by the `:await` call, but this 123 never gets to the output because we don't error handle 👀 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant