Use instantiateGun instead of logoff and catch listener errors
This commit is contained in:
parent
8146bf6d7c
commit
53a8d44f69
1 changed files with 32 additions and 20 deletions
|
|
@ -506,7 +506,7 @@ module.exports = async (
|
|||
await recreateLnServices()
|
||||
|
||||
if (GunDB.isAuthenticated()) {
|
||||
GunDB.logoff()
|
||||
GunDB.instantiateGun()
|
||||
}
|
||||
|
||||
const publicKey = await GunDB.authenticate(alias, password)
|
||||
|
|
@ -2296,9 +2296,18 @@ module.exports = async (
|
|||
: publicKey
|
||||
? gun.user(publicKey)
|
||||
: gun
|
||||
keys.forEach(key => (node = node.get(key)))
|
||||
logger.info(`fetching: ${keys}`)
|
||||
keys.forEach(key => (node = node.get(key)))
|
||||
|
||||
if (!publicKeyForDecryption || !epubForDecryption) {
|
||||
logger.warn('[GUN] Missing public key for decryption!', {
|
||||
publicKeyForDecryption,
|
||||
epubForDecryption
|
||||
})
|
||||
}
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
try {
|
||||
const listener = data => {
|
||||
logger.info(`got res for: ${keys}`)
|
||||
logger.info(data || 'falsey data (does not get logged)')
|
||||
|
|
@ -2317,6 +2326,9 @@ module.exports = async (
|
|||
|
||||
if (type === 'once') node.once(listener)
|
||||
if (type === 'load') node.load(listener)
|
||||
} catch (err) {
|
||||
logger.error('Gun Fetch Error:', err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue