use timeout in htto polls

This commit is contained in:
Daniel Lugo 2020-02-25 17:35:10 -04:00
parent 8d35874c56
commit 128ff6d02a
2 changed files with 6 additions and 4 deletions

View file

@ -299,5 +299,6 @@ module.exports = {
tryAndWait, tryAndWait,
mySecret, mySecret,
promisifyGunNode: require('./promisifygun'), promisifyGunNode: require('./promisifygun'),
asyncForEach asyncForEach,
timeout5
} }

View file

@ -1570,6 +1570,7 @@ module.exports = async (
const Events = require('../services/gunDB/contact-api/events') const Events = require('../services/gunDB/contact-api/events')
const user = require('../services/gunDB/Mediator').getUser() const user = require('../services/gunDB/Mediator').getUser()
const Key = require('../services/gunDB/contact-api/key') 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) => { app.get(`/api/gun/${GunEvent.ON_RECEIVED_REQUESTS}`, (_, res) => {
try { try {
@ -1619,7 +1620,7 @@ module.exports = async (
app.get(`/api/gun/${GunEvent.ON_AVATAR}`, async (_, res) => { app.get(`/api/gun/${GunEvent.ON_AVATAR}`, async (_, res) => {
try { try {
res.json({ 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) { } catch (err) {
res.status(500).json({ res.status(500).json({
@ -1631,7 +1632,7 @@ module.exports = async (
app.get(`/api/gun/${GunEvent.ON_DISPLAY_NAME}`, async (_, res) => { app.get(`/api/gun/${GunEvent.ON_DISPLAY_NAME}`, async (_, res) => {
try { try {
res.json({ 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) { } catch (err) {
res.status(500).json({ res.status(500).json({
@ -1643,7 +1644,7 @@ module.exports = async (
app.get(`/api/gun/${GunEvent.ON_HANDSHAKE_ADDRESS}`, async (_, res) => { app.get(`/api/gun/${GunEvent.ON_HANDSHAKE_ADDRESS}`, async (_, res) => {
try { try {
res.json({ res.json({
data: await user.get(Key.CURRENT_HANDSHAKE_ADDRESS).then() data: await timeout5(user.get(Key.CURRENT_HANDSHAKE_ADDRESS).then())
}) })
} catch (err) { } catch (err) {
res.status(500).json({ res.status(500).json({