Merge branch 'master' into bug/bad-mac-logs
This commit is contained in:
commit
ce650b3173
4 changed files with 31 additions and 69 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 */
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
const Axios = require('axios')
|
||||
const Crypto = require('crypto')
|
||||
const Storage = require('node-persist')
|
||||
const logger = require('../../config/log')
|
||||
const logger = require('../config/log')
|
||||
const httpsAgent = require('https')
|
||||
const responseTime = require('response-time')
|
||||
const uuid = require('uuid/v4')
|
||||
|
|
@ -1137,7 +1137,7 @@ module.exports = async (
|
|||
try {
|
||||
return res.json(await LV2.getChanInfo(req.body.chan_id))
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
logger.error(e)
|
||||
return res.status(500).json({
|
||||
errorMessage: e.message
|
||||
})
|
||||
|
|
@ -1172,7 +1172,7 @@ module.exports = async (
|
|||
peers: await LV2.listPeers(req.body.latestError)
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
logger.error(e)
|
||||
return res.status(500).json({
|
||||
errorMessage: e.message
|
||||
})
|
||||
|
|
@ -1240,7 +1240,7 @@ module.exports = async (
|
|||
channels: await LV2.listChannels({ active_only: false })
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
logger.error(e)
|
||||
return res.status(500).json({
|
||||
errorMessage: e.message
|
||||
})
|
||||
|
|
@ -1251,7 +1251,7 @@ module.exports = async (
|
|||
try {
|
||||
return res.json(await LV2.pendingChannels())
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
logger.error(e)
|
||||
return res.status(500).json({
|
||||
errorMessage: e.message
|
||||
})
|
||||
|
|
@ -1863,7 +1863,7 @@ module.exports = async (
|
|||
try {
|
||||
return res.json(addInvoiceRes)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
logger.error(e)
|
||||
return res.status(500).json({
|
||||
errorMessage: e.message
|
||||
})
|
||||
|
|
@ -2300,7 +2300,7 @@ module.exports = async (
|
|||
}
|
||||
return res.status(200).json(postRes)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
logger.error(e)
|
||||
return res.status(500).json({
|
||||
errorMessage:
|
||||
(typeof e === 'string' ? e : e.message) || 'Unknown error.'
|
||||
|
|
@ -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(
|
||||
data,
|
||||
publicKeyForDecryption,
|
||||
epubForDecryption
|
||||
)
|
||||
GunWriteRPC.deepDecryptIfNeeded(
|
||||
data,
|
||||
publicKeyForDecryption,
|
||||
epubForDecryption
|
||||
)
|
||||
.then(res)
|
||||
.catch(rej)
|
||||
} else {
|
||||
res(data)
|
||||
}
|
||||
|
|
@ -2987,7 +2987,7 @@ module.exports = async (
|
|||
ok: true
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
logger.error(e)
|
||||
return res.status(500).json({
|
||||
errorMessage:
|
||||
(typeof e === 'string' ? e : e.message) || 'Unknown error.'
|
||||
|
|
@ -3001,7 +3001,7 @@ module.exports = async (
|
|||
ok: true
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
logger.error(e)
|
||||
return res.status(500).json({
|
||||
errorMessage:
|
||||
(typeof e === 'string' ? e : e.message) || 'Unknown error.'
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/** @format */
|
||||
const ECCrypto = require('eccrypto')
|
||||
const Storage = require('node-persist')
|
||||
const logger = require('winston')
|
||||
const FieldError = require('../fieldError')
|
||||
const logger = require('../../config/log')
|
||||
const {
|
||||
convertBufferToBase64,
|
||||
processKey,
|
||||
|
|
@ -152,14 +152,13 @@ const decryptMessage = async ({ encryptedMessage, deviceId }) => {
|
|||
return parsedMessage
|
||||
} catch (err) {
|
||||
if (err.message?.toLowerCase() === 'bad mac') {
|
||||
console.error(
|
||||
logger.error(
|
||||
'Bad Mac!',
|
||||
err,
|
||||
convertToEncryptedMessage(encryptedMessage),
|
||||
!!keyPair
|
||||
)
|
||||
}
|
||||
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ module.exports = async () => {
|
|||
} catch(e){
|
||||
logger.error("error sending invite to channels handler")
|
||||
console.log("DOING CHANNEL INVITE THING: :(")
|
||||
console.error(e)
|
||||
logger.error(e)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue