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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error when signal isn't passed down correctly to a sub-CAF #29

Open
aguynamedben opened this issue Mar 29, 2022 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@aguynamedben
Copy link

aguynamedben commented Mar 29, 2022

Thank you (again!) for this great project. It's a lifesaver if you need to timeout Promise-based code. 馃檹

I just wanted to document a potential improvement. We have code that uses CAF to add timeouts around async code. Within one CAF function we pass signal down to sub-CAF functions. This lets us separate async logic but still have it elegantly timeout.

But! If you forget to pass signal down to a sub-CAF function that expects it, a fairly unhelpful error is show:
image

Code example

// within a CAF function, call a sub-CAF function, but we forgot to pass `signal`
yield this.getAndSyncUsers(syncRequest, conversationMembers.members, seenUsers);

// signature for the sub-CAF function, but we forgot to accept `signal`
static getAndSyncUsers = CAF(function *getAndSyncUsers(
  syncRequest: SyncRequest,
  users: Array,
  seenUsers: Object,
) {
  // ...implementation...
});
@getify getify added the enhancement New feature or request label Mar 29, 2022
@getify
Copy link
Owner

getify commented Mar 29, 2022

Thanks for the helpful suggestion. Will keep this in mind for the next update. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants