I have encountered a new error that has recently occurred. As part of a scheduled backup function, I explore a copy go each datastore and save in a bucket for later use. The following syntax has worked well over the last year, however, I suspect due to load, has now stopped working.
async function getDataStore(collection) {
return admin.firestore().collection(collection).get()
.then(querySnapshot => {
if (querySnapshot.size == 0) {
console.log('No matching request for: ' + collection);
return []
} else {
const data = [];
//Query snapshot line throwing snapshot too old error.
querySnapshot.forEach(doc => {
let data_temp = doc.data();
data_temp.doc_id = doc.id;
data.push(data_temp);
});
return data;
}
});
}
This now throws a code 9, the requested snapshot version is too old. One way I can think of overcoming this, would be to batch the request into smaller 'chunks' and save. however, I wanted to see if there was something more efficient I may be missing. Fresh eyes are always helpful.
Thanks