question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Task stop executing after block with Dapper async call

See original GitHub issue

If 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:

  1. Checkout repro: https://github.com/jindraivanek/task-bug-repro
  2. Start MSSQL server by docker commands, or change connection string to your local MSSQL server
  3. 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 of task 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:closed
  • Created 5 months ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jindraivanekcommented, Apr 26, 2023

@jindraivanek have you tested it with TaskBuilder, Ply or IcedTasks? Wondering if it works there.

@vzarytovskii Didn’t test it, I can try it later today.

0reactions
vzarytovskiicommented, Jul 19, 2023

Oh, ok, I will close it, but I still want to understand why it’s not statically compilable.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found