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

Fix bad async usage in RecipeHarvester #10329

Closed
deanmarcussen opened this issue Sep 24, 2021 · 3 comments · Fixed by #13378
Closed

Fix bad async usage in RecipeHarvester #10329

deanmarcussen opened this issue Sep 24, 2021 · 3 comments · Fixed by #13378
Labels
Milestone

Comments

@deanmarcussen
Copy link
Member

recipeDescriptors.AddRange(recipeFiles.Select(recipeFile => _recipeReader.GetRecipeDescriptor(path, recipeFile, _hostingEnvironment.ContentRootFileProvider).Result));

Uses .Result because it is wrapped in a Linq Select

Should be adapted to use Task.WhenAll as the recipe reader underlying is making use of json async methods.

@jtkech
Copy link
Member

jtkech commented Sep 25, 2021

Good catch and should be named GetRecipeDescriptorAsync() with the Async suffix

Should be adapted to use Task.WhenAll

Or just a foreach loop to do an await GetRecipeDescriptorAsync() on each recipeFile

@Piedone
Copy link
Member

Piedone commented Sep 27, 2021

"foreach loop to do an await GetRecipeDescriptorAsync()" is safer since it doesn't require thread safety.

@sebastienros
Copy link
Member

Agreed with the looped await.

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

Successfully merging a pull request may close this issue.

4 participants