fix: update generated rpc requests to not omit ConfigureAwait(false) #260
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.
What was changed
Updates the code generated rpc calls to just return the
Task<Resp>
instead of awaiting.Why?
The current code is being awaited without a
ConfigureAwait(false)
, which can cause deadlocks when being invoked inside synchronization contexts such asWindowsFormsSynchronizationContext
.Checklist
Closes
No issue created, discussed with Chad on Slack, could create an issue if desired.
How was this tested:
I ran the existing tests locally and made sure they passed.
I could add a windows-only test for this if wanted, but this is very edge case and there are a few msbuild property changes needed to get WinForms into .net6 that would have to be windows-only.
Or I guess I could write a custom SynchronizationContext that does essentially the same thing, and use it for a test?
The deadlock can be simulated by running this console application on a Windows machine:
with the following .csproj
I tested that changing
SimulateWorkflowServiceRpcAsync
to the following does not deadlock.No