restsharp / restsharp/RestSharp
Fix deadlocks in async-to-sync bridge by properly managing synchronization context
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 9.8k
- Forks
- 2.3k
- PR merge metrics
- No merged PRs in 30d
Description
Description
- Async method calls through the synchronous RunSync bridge were causing deadlocks due to improper synchronization context management
- Continuations were being queued to the thread pool instead of the custom synchronization context, breaking the synchronous execution model
- The CustomSynchronizationContext implementation needed alignment with the proven Rebus library implementation pattern
Deliverables
- Context Management: Move synchronization context setup/teardown from RunSync into CustomSynchronizationContext.Run() for cleaner separation of concerns
- Continuation Handling: Remove ConfigureAwait(false) from PostCallback to ensure all continuations execute on the custom context
- API Consistency: Add ConfigureAwait(false) to RunSync method to maintain consistent async patterns
- Code Clarity: Add comments explaining the context behavior and why ConfigureAwait is not used in PostCallback
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating RunSync and CustomSynchronizationContext, then compare their context setup, teardown, and PostCallback behavior with the proven Rebus implementation pattern. The work is done when context ownership is moved into CustomSynchronizationContext.Run(), continuations remain on the custom context, RunSync uses ConfigureAwait(false), and the context behavior is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100