I have a collection with 763 documents which I fetch 200 at a time using cursor based pagination.
I am using MongoDB Find Function and then using cursor.All to unmarshall the response into their respective data structures.
The first 3 pages (200*3 = 600) work smoothly however on the last page I see a context deadline exceeded issue.
incomplete read of message header: context deadline exceeded
Upon further inspection it’s coming from the following line of code
cursorErr := dbCursor.All(childctx, result);
This happens when the limit is set as 200, however if I change it to 163 (the exact number of documents on the last page) it works perfectly.
I tried the exact same query on Compass and it works fine.