Skip to content

Commit a412f98

Browse files
committed
fix: catch errors when connecting to the registry
1 parent 3ed207b commit a412f98

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

src/core/commands/proxy.js

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,23 @@ module.exports = async (options) => {
4141

4242
console.info('🗂️ Loading registry index from', options.registry) // eslint-disable-line no-console
4343

44-
const mirror = await request(Object.assign({}, options.request, {
45-
uri: options.registry,
46-
json: true
47-
}))
48-
49-
console.info('☎️ Dialling registry mirror', mirror.ipfs.addresses.join(',')) // eslint-disable-line no-console
50-
51-
await timeout(
52-
Promise.race(
53-
mirror.ipfs.addresses.map(addr => {
54-
return ipfs.api.swarm.connect(mirror.ipfs.addresses[0])
55-
})
56-
),
57-
options.registryConnectTimeout
58-
)
59-
.then(() => {
60-
console.info('📱️ Connected to registry') // eslint-disable-line no-console
61-
})
62-
.catch(() => {
63-
64-
})
44+
try {
45+
const mirror = await request(Object.assign({}, options.request, {
46+
uri: options.registry,
47+
json: true
48+
}))
49+
50+
console.info('☎️ Dialling registry mirror', mirror.ipfs.addresses.join(',')) // eslint-disable-line no-console
51+
52+
await timeout(
53+
ipfs.api.swarm.connect(mirror.ipfs.addresses[0]),
54+
options.registryConnectTimeout
55+
)
56+
57+
console.info('📱️ Connected to registry') // eslint-disable-line no-console
58+
} catch (error) {
59+
console.info('📴 Not connected to registry') // eslint-disable-line no-console
60+
}
6561

6662
console.info('👩‍🚀 Starting local proxy') // eslint-disable-line no-console
6763

0 commit comments

Comments
 (0)