The following code when executes, silently exits:
public async Task<IList<T>> ByAsync<T>(Expression<Func<T, bool>> predicate = null) where T : class
{
var query = containerProvider.GetContainer<T>().GetItemLinqQueryable<T>();
var iterator = (predicate != null) ? query.Where(predicate).ToFeedIterator<T>() : query.ToFeedIterator<T>();
using (iterator)
{
var results = new List<T>();
while (iterator.HasMoreResults)
{
//ERROR: This never returns and the code silently exits.
var response = await iterator.ReadNextAsync();
results.AddRange(response);
}
return results;
}
}
If I change:
var response = await iterator.ReadNextAsync();
to
var response = iterator.ReadNextAsync().GetAwaiter().GetResult();
it works. Obviously this is not ideal. It also seems to happen when upserting. Essentialy it feels like async and await is broken and I'm not sure how. I'm using the emulator locally and also the
3.39.1 version of the .NET client. Not sure how to fix. Has anyone had similar issues or am I doing something wrong here?
tried:
var response = await iterator.ReadNextAsync();
expected response but instead, program silently exits. I cannot even try/catch any error.
Normally that means that whoever calls ByAsync (or the caller of the caller, basically anyone on the stack) is not using await.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With