mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
fix(github): limit pagination concurrency to 5
This commit is contained in:
parent
56a1c1548d
commit
61ce454d35
1 changed files with 9 additions and 8 deletions
|
@ -2,6 +2,8 @@ const URL = require('url');
|
|||
const ghGot = require('gh-got');
|
||||
const delay = require('delay');
|
||||
const parseLinkHeader = require('parse-link-header');
|
||||
const pAll = require('p-all');
|
||||
|
||||
const hostRules = require('../../util/host-rules');
|
||||
const { maskToken } = require('../../util/mask');
|
||||
|
||||
|
@ -65,14 +67,13 @@ async function get(path, options, retries = 5) {
|
|||
new Array(lastPage),
|
||||
(x, i) => i + 1
|
||||
).slice(1);
|
||||
const pages = await Promise.all(
|
||||
pageNumbers.map(page => {
|
||||
const url = URL.parse(linkHeader.next.url, true);
|
||||
delete url.search;
|
||||
url.query.page = page;
|
||||
return get(URL.format(url), { ...opts, paginate: false }, retries);
|
||||
})
|
||||
);
|
||||
const queue = pageNumbers.map(page => () => {
|
||||
const url = URL.parse(linkHeader.next.url, true);
|
||||
delete url.search;
|
||||
url.query.page = page;
|
||||
return get(URL.format(url), { ...opts, paginate: false }, retries);
|
||||
});
|
||||
const pages = await pAll(queue, { concurrency: 5 });
|
||||
res.body = res.body.concat(
|
||||
...pages.filter(Boolean).map(page => page.body)
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue