[CSHARP-2225] ChangeStreamCursor MoveNext sometimes throws EndOfStreamException Created: 26/Mar/18  Updated: 28/Oct/23  Resolved: 27/Mar/18

Status: Closed
Project: C# Driver
Component/s: Operations
Affects Version/s: 2.5
Fix Version/s: 2.5.1

Type: Bug Priority: Major - P3
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Case:

 Description   

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;
        }
    }
}



 Comments   
Comment by Githook User [ 29/Mar/18 ]

Author:

{'email': 'robert@robertstam.org', 'name': 'rstam', 'username': 'rstam'}

Message: CSHARP-2225: ChangeStreamCursor MoveNext sometimes throws EndOfStreamException
Branch: v2.5.x
https://github.com/mongodb/mongo-csharp-driver/commit/557df8693fd3f570f9cdcc590e9d6f31f13191f5

Comment by Githook User [ 27/Mar/18 ]

Author:

{'email': 'robert@robertstam.org', 'name': 'rstam', 'username': 'rstam'}

Message: CSHARP-2225: ChangeStreamCursor MoveNext sometimes throws EndOfStreamException
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/e6a7e0dcf44c658af4d35b0771809eb6c5e1f3a1

Generated at Wed Feb 07 21:41:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.