mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +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 ghGot = require('gh-got');
|
||||||
const delay = require('delay');
|
const delay = require('delay');
|
||||||
const parseLinkHeader = require('parse-link-header');
|
const parseLinkHeader = require('parse-link-header');
|
||||||
|
const pAll = require('p-all');
|
||||||
|
|
||||||
const hostRules = require('../../util/host-rules');
|
const hostRules = require('../../util/host-rules');
|
||||||
const { maskToken } = require('../../util/mask');
|
const { maskToken } = require('../../util/mask');
|
||||||
|
|
||||||
|
@ -65,14 +67,13 @@ async function get(path, options, retries = 5) {
|
||||||
new Array(lastPage),
|
new Array(lastPage),
|
||||||
(x, i) => i + 1
|
(x, i) => i + 1
|
||||||
).slice(1);
|
).slice(1);
|
||||||
const pages = await Promise.all(
|
const queue = pageNumbers.map(page => () => {
|
||||||
pageNumbers.map(page => {
|
const url = URL.parse(linkHeader.next.url, true);
|
||||||
const url = URL.parse(linkHeader.next.url, true);
|
delete url.search;
|
||||||
delete url.search;
|
url.query.page = page;
|
||||||
url.query.page = page;
|
return get(URL.format(url), { ...opts, paginate: false }, retries);
|
||||||
return get(URL.format(url), { ...opts, paginate: false }, retries);
|
});
|
||||||
})
|
const pages = await pAll(queue, { concurrency: 5 });
|
||||||
);
|
|
||||||
res.body = res.body.concat(
|
res.body = res.body.concat(
|
||||||
...pages.filter(Boolean).map(page => page.body)
|
...pages.filter(Boolean).map(page => page.body)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue