reachableFrom: don't retry 💥

This commit is contained in:
Jannis R 2021-12-29 18:51:34 +01:00
parent f5962c4b7f
commit 40957d3515
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -2,7 +2,6 @@
const isObj = require('lodash/isObject') const isObj = require('lodash/isObject')
const sortBy = require('lodash/sortBy') const sortBy = require('lodash/sortBy')
const pRetry = require('p-retry')
const omit = require('lodash/omit') const omit = require('lodash/omit')
const defaultProfile = require('./lib/default-profile') const defaultProfile = require('./lib/default-profile')
@ -619,7 +618,7 @@ const createClient = (profile, userAgent, opt = {}) => {
}) })
} }
const reachableFrom = (address, opt = {}) => { const reachableFrom = async (address, opt = {}) => {
validateLocation(address, 'address') validateLocation(address, 'address')
opt = Object.assign({ opt = Object.assign({
@ -635,9 +634,7 @@ const createClient = (profile, userAgent, opt = {}) => {
const req = profile.formatReachableFromReq({profile, opt}, address) const req = profile.formatReachableFromReq({profile, opt}, address)
const refetch = () => { const {res, common} = await profile.request({profile, opt}, userAgent, req)
return profile.request({profile, opt}, userAgent, req)
.then(({res, common}) => {
if (!Array.isArray(res.posL)) { if (!Array.isArray(res.posL)) {
const err = new Error('invalid response') const err = new Error('invalid response')
err.shouldRetry = true err.shouldRetry = true
@ -660,16 +657,9 @@ const createClient = (profile, userAgent, opt = {}) => {
byDuration[i].stations.push(loc) byDuration[i].stations.push(loc)
} }
} }
// todo [breaking]: return object with realtimeDataUpdatedAt // todo [breaking]: return object with realtimeDataUpdatedAt
return byDuration return byDuration
})
}
return pRetry(refetch, {
retries: 3,
factor: 2,
minTimeout: 2 * 1000
})
} }
const remarks = async (opt = {}) => { const remarks = async (opt = {}) => {