-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[BUG] Use of Task.Result directly blocks thread #19176
Comments
can you please file a PR with the suggested fix when you've time? |
My solution was not correct, my suggestion is to revert the changes in the PR. |
@filipe-silva can you please review this issue reported by @rfriend-zilo when you've time? |
- async should never be blocked on the ApiClient To fix we invert the logic and use Task as base and keep consistency, we expect and wait result only on synchronous calls.
This concern makes sense, I did a fix to resolve this issue. |
@filipe-silva can you please file a new PR? |
@rfriend-zilo can you please review the fix when you've time? |
- async should never be blocked on the ApiClient To fix we invert the logic and use Task as base and keep consistency, we expect and wait result only on synchronous calls.
Bug Report Checklist
Description
The direct call here to Task.Result is blocking the thread, and when used in a blazor application prevents UI from rendering :
openapi-generator/modules/openapi-generator/src/main/resources/csharp/ApiClient.mustache
Line 628 in 9ae8775
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/18915/files/0639c25fe8affd4c6ad8ea3d26711cc0f83a7bf1
Suggest a fix
Rather than calling async code from sync code using .Result, inside ExecAsync just await action() then construct Func<RestClient, RestResponse> getResponse using the result from that awaited call.
The text was updated successfully, but these errors were encountered: