I've been refactoring a legacy Web API recently, and after switching several endpoints to use async Task and await, I'm suddenly seeing sporadic 500 errors that look like deadlocks. The stack traces mention SynchronizationContext and TaskScheduler, which I don't fully understand.
My controllers are inheriting from ControllerBase in a standard ASP.NET Core app. I'm calling EF Core SaveChangesAsync() and some third-party HTTP clients with await, but I'm not sure if I'm doing something wrong with the context capture or if it's something else entirely.
Has anyone else run into this? What are the common pitfalls when moving from synchronous to asynchronous controller actions in this framework?
Can you answer this question?
Write Answer0 Answers