From 7c51a5388826515b829f3c064aeaa5cc9d8b6928 Mon Sep 17 00:00:00 2001 From: emad-salah Date: Mon, 2 Aug 2021 12:50:17 +0100 Subject: [PATCH 1/2] Create new alias timeout fixed --- services/gunDB/Mediator/index.js | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/services/gunDB/Mediator/index.js b/services/gunDB/Mediator/index.js index c57091fa..fd13c439 100644 --- a/services/gunDB/Mediator/index.js +++ b/services/gunDB/Mediator/index.js @@ -543,31 +543,14 @@ const register = async (alias, pass) => { } if (theresPeers && atLeastOneIsConnected) { - // this import is done here to avoid circular dependency hell - const { timeout5 } = require('../contact-api/utils') - - let userData = await timeout5( - new Promise(res => { - gun.get(`~@${alias}`).once(ud => res(ud)) - }) - ) - - if (userData) { - throw new Error( - 'The given alias has been used before, use an unique alias instead.' - ) - } - await new Promise(res => setTimeout(res, 300)) - userData = await timeout5( - new Promise(res => { - gun.get(`~@${alias}`).once(ud => res(ud), { - // https://github.com/amark/gun/pull/971#issue-438630761 - wait: 1500 - }) + const userData = await new Promise(res => { + gun.get(`~@${alias}`).once(ud => res(ud), { + // https://github.com/amark/gun/pull/971#issue-438630761 + wait: 1500 }) - ) + }) if (userData) { throw new Error( From d279f5eb2fa1498a8103dc4ed00ec0a0844541cd Mon Sep 17 00:00:00 2001 From: emad-salah Date: Mon, 2 Aug 2021 12:51:59 +0100 Subject: [PATCH 2/2] Error spelling fixes --- services/gunDB/Mediator/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/gunDB/Mediator/index.js b/services/gunDB/Mediator/index.js index fd13c439..e84ac866 100644 --- a/services/gunDB/Mediator/index.js +++ b/services/gunDB/Mediator/index.js @@ -538,7 +538,7 @@ const register = async (alias, pass) => { if (theresPeers && !atLeastOneIsConnected) { throw new Error( - 'No connected to any peers for checking of duplicate aliases' + 'Not connected to any peers for checking of duplicate aliases' ) } @@ -554,7 +554,7 @@ const register = async (alias, pass) => { if (userData) { throw new Error( - 'The given alias has been used before, use an unique alias instead. (Caught at 2nd try)' + 'The given alias has been used before, use a unique alias instead. (Caught at 2nd try)' ) } }