Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[Breaking] support passing in an async function for the test callback #472
[Breaking] support passing in an async function for the test callback #472
Changes from all commits
8d3f03a
f248610
197019c
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that using
setTimeout
alone in a world of promises slash async/await is a bug. This should beawait
ing anew Promise
that wraps thesetTimeout
, so that its fate is tied to the overarching promise of the async function.I've fixed this in the rebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s a bad practice but not a bug.
I’ve seen plenty of people mixing promises, async/await and callbacks
Adding ‘data’ listeners is the biggest example of mixing callbacks and promises.
This is a best practice we will need to educate the tape users on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider those two things the same thing :-)
If you're returning a promise - which is always the case when using an
async function
- you are explicitly stating that your function resolves to a single future async value. Thus, every single async action you create needs to be tied to the fate of that promise.If that's not the case, take a callback and don't be an async function/don't return a promise.
I agree educating tape users might be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agreed, mixing callbacks & promises is a terrible idea.
But I suspect our users might do it none the less and tape already "supports" async functions if you call
t.end()
and happen to not throw an exception so we might break existing tests