thrownewError(`Got unexpected status code ${response.statusCode}`);
}
}).catch({code:"ECONNREFUSED"},(_error)=>{
// Scraping server is down, try again in a minute or so
console.warn("WARNING: Scraping server is not reachable! Retrying in a minute...");
returnPromise.try(()=>{
returnPromise.delay(60*1000);
}).then(()=>{
returnattempt();
});
});
});
});
}
returnattempt();
}),
createCombineSequentialStream(),
createNDJSONParseStream(),
createSpyStream((item)=>{
if(item.updatedAt!=null){
// TODO: Can this be made significantly more performant by string-sorting the timestamps in ISO format directly, instead of going through a parsing cycle?
letitemDate=newDate(item.updatedAt);
if(itemDate>lastTimestamp){
lastTimestamp=itemDate;
}
}
}
})
returnattempt();
]);
}),
createCombineSequentialStream(),
createNDJSONParseStream(),
createSpyStream((item)=>{
if(item.updatedAt!=null){
// TODO: Can this be made significantly more performant by string-sorting the timestamps in ISO format directly, instead of going through a parsing cycle?