Skip to content

Commit 2c37516

Browse files
committed
Do not cache dnslink lookup when API is offline
1 parent 0d53002 commit 2c37516

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/api.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function isDnslinkPresent (fqdn) {
5757
try {
5858
xhr.send(null)
5959
} catch (e) {
60-
return false
60+
return null
6161
}
6262
if (xhr.status === 200) {
6363
let json = JSON.parse(xhr.responseText)
@@ -71,9 +71,11 @@ function isDnslinkPresentCached (fqdn) {
7171
let ipfsSupport = dnsCache.get(fqdn)
7272
if (typeof ipfsSupport === 'undefined') {
7373
ipfsSupport = isDnslinkPresent(fqdn)
74-
dnsCache.put(fqdn, ipfsSupport)
74+
if (ipfsSupport !== null) { // dont cache is API was down
75+
dnsCache.put(fqdn, ipfsSupport)
76+
}
7577
}
76-
return ipfsSupport
78+
return !!ipfsSupport
7779
}
7880

7981
exports.apiUrl = apiUrl

0 commit comments

Comments
 (0)