first retry should be quickly after first try

This commit is contained in:
Daniel Lugo 2020-08-02 13:13:20 -04:00
parent f04c1a3728
commit 724350ebd7

View file

@ -116,6 +116,36 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
` args: ${promGen.toString()} -- ${shouldRetry.toString()}` ` args: ${promGen.toString()} -- ${shouldRetry.toString()}`
) )
await delay(200)
try {
resolvedValue = await timeout5(
promGen(
require('../../Mediator/index').getGun(),
require('../../Mediator/index').getUser()
)
)
if (shouldRetry(resolvedValue)) {
logger.info(
'force retrying' +
` args: ${promGen.toString()} -- ${shouldRetry.toString()} \n resolvedValue: ${resolvedValue}, type: ${typeof resolvedValue}`
)
} else {
return resolvedValue
}
} catch (e) {
logger.error(e)
if (e.message === 'NOT_AUTH') {
throw e
}
}
logger.info(
`\n retrying \n` +
` args: ${promGen.toString()} -- ${shouldRetry.toString()}`
)
await delay(3000) await delay(3000)
try { try {