Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(serverless-hub) retry logic bug #2117

Merged
merged 4 commits into from
Oct 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ hub.post("/", async (req, res) => {
// Fetch the last block number this given config file queried the blockchain at if running in production. Else, pull from env.
const lastQueriedBlockNumber = await _getLastQueriedBlockNumber(req.body.configFile);
if (!configObject || !lastQueriedBlockNumber)
throw new Error("Serverless hub requires a config object and a last updated block number!");
throw new Error(
`Serverless hub requires a config object and a last updated block number! configObject:${JSON.stringify(
configObject
)} lastQueriedBlockNumber:${lastQueriedBlockNumber}`
);

// Get the latest block number. The query will run from the last queried block number to the latest block number.
const latestBlockNumber = await _getLatestBlockNumber();
Expand Down Expand Up @@ -261,7 +265,7 @@ async function _saveQueriedBlockNumber(configIdentifier, blockNumber) {
// recorded by the bot to inform where searches should start from.
async function _getLastQueriedBlockNumber(configIdentifier) {
// sometimes the GCP datastore can be flaky and return errors when saving data. Use re-try logic to re-run on error.
await retry(
return await retry(
async () => {
if (hubConfig.saveQueriedBlock == "gcp") {
const key = datastore.key(["BlockNumberLog", configIdentifier]);
Expand Down