Skip to content

Commit

Permalink
fix: catch errors when connecting to the registry
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Dec 10, 2018
1 parent 3ed207b commit a412f98
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions src/core/commands/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a412f98

Please sign in to comment.