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

Misuse of resolve/reject causes "close of closed channel" panic #17

Open
yoavsv opened this issue Dec 5, 2022 · 0 comments
Open

Misuse of resolve/reject causes "close of closed channel" panic #17

yoavsv opened this issue Dec 5, 2022 · 0 comments

Comments

@yoavsv
Copy link

yoavsv commented Dec 5, 2022

Hello,

If I run:

mo.NewFuture(func(resolve func(struct{}), reject func(error)) {
	resolve(struct{}{})
	reject(errors.New("oh no..."))
})

I get panic: close of closed channel.

This makes me write defensive code (e.g. return after each call to reject / resolve).
I would suggest to recover from panics and reflect it as an error as part of Result[T]'s error.

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

2 participants
@yoavsv and others