Skip to content
Snippets Groups Projects
Commit b6ee52e7 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix(github): do not retry blog size 403s

parent dd09707c
No related merge requests found
......@@ -95,6 +95,12 @@ async function get(path, opts, retries = 5) {
) {
logger.info({ err }, 'Rate limit exceeded');
throw new Error('rate-limit-exceeded');
} else if (
err.statusCode === 403 &&
err.message &&
err.message.includes('blobs up to 1 MB in size')
) {
throw err;
} else if (err.statusCode === 403) {
if (retries > 0) {
logger.info(
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`platform/gh-got-wrapper should throw for blob size 1`] = `
Object {
"message": "This API returns blobs up to 1 MB in size. The requested blob is too large to fetch via the API, but you can use the Git Data API to request blobs up to 100 MB in size. (403)",
"statusCode": 403,
}
`;
......@@ -90,6 +90,23 @@ describe('platform/gh-got-wrapper', () => {
expect(e).toBeDefined();
expect(e.message).toEqual('bad-credentials');
});
it('should throw for blob size', async () => {
ghGot.mockImplementationOnce(() =>
Promise.reject({
statusCode: 403,
message:
'This API returns blobs up to 1 MB in size. The requested blob is too large to fetch via the API, but you can use the Git Data API to request blobs up to 100 MB in size. (403)',
})
);
let e;
try {
await get('some-url');
} catch (err) {
e = err;
}
expect(e).toBeDefined();
expect(e).toMatchSnapshot();
});
it('should retry 502s', async () => {
ghGot.mockImplementationOnce(() =>
Promise.reject({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment