Task stop executing after block with Dapper async call
See original GitHub issueIf task {}
have certain depth it silently stop executing after let!
block that contains Dapper async call.
This is connected to Dapper library, but because I think this behavior should never happen, regardless of code inside task, I am raising issue here.
Repro code here: https://github.com/jindraivanek/task-bug-repro
Repro steps
Provide the steps required to reproduce the problem:
- Checkout repro: https://github.com/jindraivanek/task-bug-repro
- Start MSSQL server by docker commands, or change connection string to your local MSSQL server
- Run project, program will not end, task complexTask will never finish, second
let!
bock is never executed.
Expected behavior
Task should never silently stop executing.
Actual behavior
Task stop executing after first let!
block with Dapper async call. (But not during or after Dapper call, all code in this block is executed.)
Known workarounds
- use synchronous variant of Dapper method
- refactor to have less depth of task
- use
async
instead oftask
All these workaround are showcased in repro code.
Related information
Reproduced with MSSQL, does not reproduce with SQLite, didn’t test on another databases.
- Operating system Windows 10
- .NET Runtime kind (.NET Core, .NET Framework, Mono) .NET 7
- Editing Tools (e.g. Visual Studio Version, Visual Studio) not important, but Rider
Issue Analytics
- State:
- Created 5 months ago
- Reactions:1
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Using Async and Await to break up database call (with ...
One solution that can work in some cases would be to use ConfigureAwait(false) which means that the continuation can be run on any...
Read more >Stackoverflow when using async methods · Issue #1475
I'm using Dapper in a .net core app to connect to a postgres database using ... The stack overflow happens and the program...
Read more >Async methods are blocking execution · Issue #531
I have the following code: using Dapper; using MySql.Data. ... Note: you probably shouldn't be calling Wait, either - await is preferable
Read more >Net Async Await, the Good, the Bad and the Deadlocks
The task we are awaiting here is a database call (using Dapper) which will block. So in short, this method will run to...
Read more >A Practical Guide to Dapper - Simple Talk
Dapper is a lightweight framework for data access. Camilo Reyes explains how to query, call stored procedures, and more with Dapper in C#....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vzarytovskii Didn’t test it, I can try it later today.
Oh, ok, I will close it, but I still want to understand why it’s not statically compilable.