From 128ff6d02a1684518cfd72445393bacd9f740355 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Tue, 25 Feb 2020 17:35:10 -0400 Subject: [PATCH] use timeout in htto polls --- services/gunDB/contact-api/utils/index.js | 3 ++- src/routes.js | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/gunDB/contact-api/utils/index.js b/services/gunDB/contact-api/utils/index.js index a71ef8ec..c00b68f7 100644 --- a/services/gunDB/contact-api/utils/index.js +++ b/services/gunDB/contact-api/utils/index.js @@ -299,5 +299,6 @@ module.exports = { tryAndWait, mySecret, promisifyGunNode: require('./promisifygun'), - asyncForEach + asyncForEach, + timeout5 } diff --git a/src/routes.js b/src/routes.js index 4ee69623..a7ef7b46 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1570,6 +1570,7 @@ module.exports = async ( const Events = require('../services/gunDB/contact-api/events') const user = require('../services/gunDB/Mediator').getUser() const Key = require('../services/gunDB/contact-api/key') + const {timeout5} = require('../services/gunDB/contact-api/utils') app.get(`/api/gun/${GunEvent.ON_RECEIVED_REQUESTS}`, (_, res) => { try { @@ -1619,7 +1620,7 @@ module.exports = async ( app.get(`/api/gun/${GunEvent.ON_AVATAR}`, async (_, res) => { try { res.json({ - data: await user.get(Key.PROFILE).get(Key.AVATAR).then() + data: await timeout5(user.get(Key.PROFILE).get(Key.AVATAR).then()) }) } catch (err) { res.status(500).json({ @@ -1631,7 +1632,7 @@ module.exports = async ( app.get(`/api/gun/${GunEvent.ON_DISPLAY_NAME}`, async (_, res) => { try { res.json({ - data: await user.get(Key.PROFILE).get(Key.DISPLAY_NAME).then() + data: await timeout5(user.get(Key.PROFILE).get(Key.DISPLAY_NAME).then()) }) } catch (err) { res.status(500).json({ @@ -1643,7 +1644,7 @@ module.exports = async ( app.get(`/api/gun/${GunEvent.ON_HANDSHAKE_ADDRESS}`, async (_, res) => { try { res.json({ - data: await user.get(Key.CURRENT_HANDSHAKE_ADDRESS).then() + data: await timeout5(user.get(Key.CURRENT_HANDSHAKE_ADDRESS).then()) }) } catch (err) { res.status(500).json({