Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2225

ChangeStreamCursor MoveNext sometimes throws EndOfStreamException

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.1
    • Affects Version/s: 2.5
    • Component/s: Operations
    • None

      When calling cursor.MoveNext for a ChangeStreamCursor an EndOfStreamException will be thrown if the batch returned from the server is larger than 64KB.

      Can be reproduced for any numberOfChunks >= 1 as follows:

      var pipeline = new EmptyPipelineDefinition<ChangeStreamDocument<BsonDocument>>();
      var options = new ChangeStreamOptions() { FullDocument = ChangeStreamFullDocumentOption.UpdateLookup };
      using (var cursor = collection.Watch(pipeline, options))
      {
          var numberOfChunks = 1;
          var filler = new string('x', (numberOfChunks - 1) * 65536);
          var document = new BsonDocument { { "_id", 1 }, { "filler", filler } };
          collection.InsertOne(document);
      
          while (true)
          {
              cursor.MoveNext();
              var change = cursor.Current.FirstOrDefault();
              if (change != null)
              {
                  break;
              }
          }
      }
      

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: