# File lib/mongo/collection/view/change_stream.rb, line 115 def each raise StopIteration.new if closed? retried = false begin @cursor.each do |doc| cache_resume_token(doc) yield doc end if block_given? @cursor.to_enum rescue Mongo::Error => e if retried || !e.change_stream_resumable? raise end retried = true # Rerun initial aggregation. # Any errors here will stop iteration and break out of this # method close create_cursor! retry end end