mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
fix(packagist): gracefully handle ETIMEDOUT and 403
This commit is contained in:
parent
3f6b37f1ea
commit
490bc3567a
2 changed files with 18 additions and 2 deletions
|
@ -52,7 +52,11 @@ async function getRegistryMeta(regUrl) {
|
|||
}
|
||||
return meta;
|
||||
} catch (err) {
|
||||
if (err.statusCode === 401) {
|
||||
if (err.code === 'ETIMEDOUT') {
|
||||
logger.info({ regUrl }, 'Packagist timeout');
|
||||
return null;
|
||||
}
|
||||
if (err.statusCode === 401 || err.statusCode === 403) {
|
||||
logger.info({ regUrl }, 'Unauthorized Packagist repository');
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -89,10 +89,22 @@ describe('datasource/packagist', () => {
|
|||
});
|
||||
expect(res).toMatchSnapshot();
|
||||
});
|
||||
it('handles timeouts', async () => {
|
||||
got.mockImplementationOnce(() =>
|
||||
Promise.reject({
|
||||
code: 'ETIMEDOUT',
|
||||
})
|
||||
);
|
||||
const res = await datasource.getPkgReleases({
|
||||
...config,
|
||||
lookupName: 'vendor/package-name2',
|
||||
});
|
||||
expect(res).toBeNull();
|
||||
});
|
||||
it('handles auth rejections', async () => {
|
||||
got.mockImplementationOnce(() =>
|
||||
Promise.reject({
|
||||
statusCode: 401,
|
||||
statusCode: 403,
|
||||
})
|
||||
);
|
||||
const res = await datasource.getPkgReleases({
|
||||
|
|
Loading…
Reference in a new issue