mongos in cursors.cpp only sets batch size (and always sets batch size) after a document is returned. This leads to the batch size being set to 0 every time a full load of ntoreturn documents are sent back to the client. If the cursor is exhausted at that point, then the next getMore request to the mongoD (which will be sent on the next will request to the mongoS) will have a batch size of 0. This returns all results and can lead to cursors timing out.
Moving the setBatchSize before the loop starts and after all breaks (so no useless work is performed setting an invalid batch size on break) should fix this.