Retry 'endpoint is in transition' db errors

This commit is contained in:
Sam Becker 2023-09-10 23:41:41 -05:00
parent b928afac7b
commit adb0669ab6

View File

@ -177,6 +177,15 @@ export const getPhotos = async (
); );
await sqlCreatePhotosTable(); await sqlCreatePhotosTable();
photos = await getPhotosRequest(limit, offset); photos = await getPhotosRequest(limit, offset);
} else if (/endpoint is in transition/i.test(e.message)) {
// Wait 5 seconds and try again
await new Promise(resolve => setTimeout(resolve, 5000));
try {
photos = await getPhotosRequest(limit, offset);
} catch (e: any) {
console.log(`sql get error on retry (after 5000ms): ${e.message} `);
throw e;
}
} else { } else {
console.log(`sql get error: ${e.message} `); console.log(`sql get error: ${e.message} `);
throw e; throw e;