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

[BUG] Use of Task.Result directly blocks thread #19176

Closed
4 tasks
rfriend-zilo opened this issue Jul 16, 2024 · 6 comments · Fixed by #19231
Closed
4 tasks

[BUG] Use of Task.Result directly blocks thread #19176

rfriend-zilo opened this issue Jul 16, 2024 · 6 comments · Fixed by #19231

Comments

@rfriend-zilo
Copy link

rfriend-zilo commented Jul 16, 2024

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • [ x] Have you tested with the latest master to confirm the issue still exists?
  • [x ] Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The direct call here to Task.Result is blocking the thread, and when used in a blazor application prevents UI from rendering :

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.

@wing328
Copy link
Member

wing328 commented Jul 16, 2024

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.

can you please file a PR with the suggested fix when you've time?

@rfriend-zilo
Copy link
Author

My solution was not correct, my suggestion is to revert the changes in the PR.

@wing328
Copy link
Member

wing328 commented Jul 19, 2024

@filipe-silva can you please review this issue reported by @rfriend-zilo when you've time?

filipe-silva added a commit to filipe-silva/openapi-generator that referenced this issue Jul 20, 2024
 - 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.
@filipe-silva
Copy link
Contributor

filipe-silva commented Jul 20, 2024

@filipe-silva can you please review this issue reported by @rfriend-zilo when you've time?

This concern makes sense, I did a fix to resolve this issue.
How do I merge it or include it in this PR?

@wing328
Copy link
Member

wing328 commented Jul 20, 2024

@filipe-silva can you please file a new PR?

@wing328
Copy link
Member

wing328 commented Jul 24, 2024

@rfriend-zilo can you please review the fix when you've time?

#19231

wing328 pushed a commit that referenced this issue Aug 4, 2024
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants