Skip to content

FeedIterator.ReadNextAsync blocks in v3.38.0+ #4695

@tobywicks-cv

Description

@tobywicks-cv

Problem occurs in v3.43.0

Describe the bug
FeedIterator<>.ReadNextAsync() blocks indefinitely when existing in a .NET 4.8 web forms app (presumably running in AspNetSynchronizationContext). This issue does not occur when running in a console app.

To Reproduce

  1. Configure a CosmosDB with a container.
  2. Execute the following with updated end point details etc.
  var endpointUri = "*****";
  var primaryKey = "*****";
  var databaseId = "*****";
  var containerId = "*****";

  var cosmosClient = new CosmosClient(endpointUri, primaryKey);
  var container = cosmosClient.GetContainer(databaseId, containerId);

  var sqlQueryText = "SELECT * FROM c";
  var queryDefinition = new QueryDefinition(sqlQueryText);
  var queryResultSetIterator = container.GetItemQueryIterator<dynamic>(queryDefinition);
  
  while (queryResultSetIterator.HasMoreResults)
  {
      foreach (var item in await queryResultSetIterator.ReadNextAsync().ConfigureAwait(false))   // <- blocks here
      {
          Console.WriteLine(item);
      }
  }

Expected behavior
Call to queryResultSetIterator.ReadNextAsync does not block indefinitely and returns the data in the container.

Actual behavior
Call to queryResultSetIterator.ReadNextAsync blocks indefinitely.

Environment summary
SDK Version: Framework 4.8.1
OS Version: Windows 11

Additional context
Seems like this issue was introduced in v3.38.0. v3.37.1 does not block. So I'm using that version for the moment.

Metadata

Metadata

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions