Merge pull request #429 from shocknet/timeout-err-stack
Timeout err stack
This commit is contained in:
commit
dffc0e7252
2 changed files with 19 additions and 56 deletions
|
|
@ -101,7 +101,6 @@ const timeout2 = promise => {
|
|||
* @returns {Promise<T>}
|
||||
*/
|
||||
const tryAndWait = async (promGen, shouldRetry = () => false) => {
|
||||
/* eslint-disable no-empty */
|
||||
/* eslint-disable init-declarations */
|
||||
|
||||
// If hang stop at 10, wait 3, retry, if hang stop at 5, reinstate, warm for
|
||||
|
|
@ -118,28 +117,15 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
|
|||
)
|
||||
)
|
||||
|
||||
if (shouldRetry(resolvedValue)) {
|
||||
logger.info(
|
||||
'force retrying' /* +
|
||||
` args: ${promGen.toString()} -- ${shouldRetry.toString()} \n resolvedValue: ${resolvedValue}, type: ${typeof resolvedValue}`
|
||||
*/
|
||||
)
|
||||
} else {
|
||||
if (!shouldRetry(resolvedValue)) {
|
||||
return resolvedValue
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
if (e.message === Constants.ErrorCode.NOT_AUTH) {
|
||||
if (e.message !== Constants.ErrorCode.TIMEOUT_ERR) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`\n retrying \n` /* +
|
||||
` args: ${promGen.toString()} -- ${shouldRetry.toString()}`
|
||||
*/
|
||||
)
|
||||
|
||||
await delay(200)
|
||||
|
||||
try {
|
||||
|
|
@ -150,28 +136,15 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
|
|||
)
|
||||
)
|
||||
|
||||
if (shouldRetry(resolvedValue)) {
|
||||
logger.info(
|
||||
'force retrying' /* +
|
||||
` args: ${promGen.toString()} -- ${shouldRetry.toString()} \n resolvedValue: ${resolvedValue}, type: ${typeof resolvedValue}`
|
||||
*/
|
||||
)
|
||||
} else {
|
||||
if (!shouldRetry(resolvedValue)) {
|
||||
return resolvedValue
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
if (e.message === Constants.ErrorCode.NOT_AUTH) {
|
||||
if (e.message !== Constants.ErrorCode.TIMEOUT_ERR) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`\n retrying \n` /* +
|
||||
` args: ${promGen.toString()} -- ${shouldRetry.toString()}`
|
||||
*/
|
||||
)
|
||||
|
||||
await delay(3000)
|
||||
|
||||
try {
|
||||
|
|
@ -182,32 +155,22 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
|
|||
)
|
||||
)
|
||||
|
||||
if (shouldRetry(resolvedValue)) {
|
||||
logger.info(
|
||||
'force retrying' /* +
|
||||
` args: ${promGen.toString()} -- ${shouldRetry.toString()} \n resolvedValue: ${resolvedValue}, type: ${typeof resolvedValue}`
|
||||
*/
|
||||
)
|
||||
} else {
|
||||
if (!shouldRetry(resolvedValue)) {
|
||||
return resolvedValue
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
if (e.message === Constants.ErrorCode.NOT_AUTH) {
|
||||
if (e.message !== Constants.ErrorCode.TIMEOUT_ERR) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`\n NOT recreating a fresh gun but retrying one last time \n` /* +
|
||||
` args: ${promGen.toString()} -- ${shouldRetry.toString()}`
|
||||
*/
|
||||
return timeout10(
|
||||
promGen(
|
||||
require('../../Mediator/index').getGun(),
|
||||
require('../../Mediator/index').getUser()
|
||||
)
|
||||
)
|
||||
|
||||
const { gun, user } = require('../../Mediator/index').freshGun()
|
||||
|
||||
return timeout10(promGen(gun, user))
|
||||
/* eslint-enable no-empty */
|
||||
/* eslint-enable init-declarations */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2725,16 +2725,16 @@ module.exports = async (
|
|||
: gun
|
||||
keys.forEach(key => (node = node.get(key)))
|
||||
|
||||
return new Promise(res => {
|
||||
const listener = async data => {
|
||||
return new Promise((res, rej) => {
|
||||
const listener = data => {
|
||||
if (publicKeyForDecryption) {
|
||||
res(
|
||||
await GunWriteRPC.deepDecryptIfNeeded(
|
||||
GunWriteRPC.deepDecryptIfNeeded(
|
||||
data,
|
||||
publicKeyForDecryption,
|
||||
epubForDecryption
|
||||
)
|
||||
)
|
||||
.then(res)
|
||||
.catch(rej)
|
||||
} else {
|
||||
res(data)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue