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

Fixing async voids (Lombiq Technologies: OCORE-192) #16441

Merged
merged 2 commits into from
Jul 15, 2024

Conversation

Piedone
Copy link
Member

@Piedone Piedone commented Jul 15, 2024

async void is fire-and-forget, meaning that the code may or may not complete before the next line, making it unreliable. Exceptions thrown from such methods can also bring down the whole app. The only case where it's recommended for are event handles, see the official docs. So, fixing those here.

I also searched for less trivial cases with async (?!(Task|ValueTask|scope|override)\b)\w+ but couldn't find any.

@Piedone Piedone requested a review from MikeAlhayek July 15, 2024 13:12
Copy link
Member

@MikeAlhayek MikeAlhayek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are an unintentional mistakes. I wish we have analyzers that would guard against this. I think VS auto adds the async if await is used instead of complaining "await is being used in a synchronous code".

@MikeAlhayek MikeAlhayek merged commit 20f5aa4 into OrchardCMS:main Jul 15, 2024
11 checks passed
@Piedone
Copy link
Member Author

Piedone commented Jul 15, 2024

There are analyzers for this that we can add under #7950.

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

Successfully merging this pull request may close these issues.

2 participants