From a412f98186a187db4693196323253b12a0b5b4fb Mon Sep 17 00:00:00 2001 From: achingbrain Date: Mon, 10 Dec 2018 16:06:48 +0000 Subject: [PATCH] fix: catch errors when connecting to the registry --- src/core/commands/proxy.js | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/core/commands/proxy.js b/src/core/commands/proxy.js index b8ec4dcb..92c7b181 100644 --- a/src/core/commands/proxy.js +++ b/src/core/commands/proxy.js @@ -41,27 +41,23 @@ module.exports = async (options) => { console.info('🗂️ Loading registry index from', options.registry) // eslint-disable-line no-console - const mirror = await request(Object.assign({}, options.request, { - uri: options.registry, - json: true - })) - - console.info('☎️ Dialling registry mirror', mirror.ipfs.addresses.join(',')) // eslint-disable-line no-console - - await timeout( - Promise.race( - mirror.ipfs.addresses.map(addr => { - return ipfs.api.swarm.connect(mirror.ipfs.addresses[0]) - }) - ), - options.registryConnectTimeout - ) - .then(() => { - console.info('📱️ Connected to registry') // eslint-disable-line no-console - }) - .catch(() => { - - }) + try { + const mirror = await request(Object.assign({}, options.request, { + uri: options.registry, + json: true + })) + + console.info('☎️ Dialling registry mirror', mirror.ipfs.addresses.join(',')) // eslint-disable-line no-console + + await timeout( + ipfs.api.swarm.connect(mirror.ipfs.addresses[0]), + options.registryConnectTimeout + ) + + console.info('📱️ Connected to registry') // eslint-disable-line no-console + } catch (error) { + console.info('📴 Not connected to registry') // eslint-disable-line no-console + } console.info('👩‍🚀 Starting local proxy') // eslint-disable-line no-console