Skip to content

Commit

Permalink
fix: condition under no tunnel
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 17, 2019
1 parent 3a014f4 commit a1866f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const makeError = ({ rawError, url, flags }) => {

module.exports = ({ tunnel, onError, userAgent, cacheDir }) => {
const retry = expirableCounter()
const hasTunnelAvailable = () => tunnel && retry.val() < tunnel.size()

return async url => {
let data = {}
do {
Expand All @@ -74,7 +76,7 @@ module.exports = ({ tunnel, onError, userAgent, cacheDir }) => {
if (!tunnel && isTwitterRateLimit(url, err)) return data
retry.incr()
}
} while (isEmpty(data) && retry.val() < tunnel.size())
} while (isEmpty(data) && hasTunnelAvailable())
return data
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const TWITTER_BEARER_TOKEN =

const createGuestToken = ({ userAgent, tunnel }) => {
const retry = expirableCounter()
const hasTunnelAvailable = () => tunnel && retry.val() < tunnel.size()

return async () => {
let token
Expand Down Expand Up @@ -46,7 +47,7 @@ const createGuestToken = ({ userAgent, tunnel }) => {
debug('guestToken:err', err.message)
retry.incr()
}
} while (!token && retry.val() < tunnel.size())
} while (!token && hasTunnelAvailable())

return token
}
Expand Down

0 comments on commit a1866f1

Please sign in to comment.