Skip to content

Commit

Permalink
fix: don't loop if max tunnel size is reached
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Oct 17, 2019
1 parent 9c93975 commit 3a014f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/metascraper-media-provider/bench/constants.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
apiKey: process.env.MICROLINK_API_KEY,
proxies: [process.env.PROXY_ONE, process.env.PROXY_TWO],
proxies: process.env.PROXIES.split(','),
urls: [
'https://twitter.com/Tour_du_Rwanda/status/1111166645475700737',
'https://twitter.com/Visit_Murcia/status/1036982439829225472',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ const makeError = ({ rawError, url, flags }) => {
}

module.exports = ({ tunnel, onError, userAgent, cacheDir }) => {
const retry = expirableCounter(1)

const retry = expirableCounter()
return async url => {
let data = {}
do {
Expand All @@ -71,11 +70,11 @@ module.exports = ({ tunnel, onError, userAgent, cacheDir }) => {
} catch (rawError) {
const err = makeError({ rawError, url, flags })
debug('getInfo:err', err.message)
retry.incr()
onError(err, url)
if (!(tunnel && isTwitterRateLimit(url, err))) return data
if (!tunnel && isTwitterRateLimit(url, err)) return data
retry.incr()
}
} while (isEmpty(data))
} while (isEmpty(data) && retry.val() < tunnel.size())
return data
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const createGuestToken = ({ userAgent, tunnel }) => {
debug('guestToken:err', err.message)
retry.incr()
}
} while (!token)
} while (!token && retry.val() < tunnel.size())

return token
}
Expand Down

0 comments on commit 3a014f4

Please sign in to comment.