From ccdd48474c77718db1f169fff8ab688a9f570327 Mon Sep 17 00:00:00 2001 From: Alejandro Corredor Date: Thu, 22 Feb 2024 15:15:04 -0500 Subject: [PATCH 1/2] feat: axios 0.28.0 --- .github/workflows/release.yaml | 1 + package.json | 2 +- release.config.js | 2 +- src/alpha.ts | 4 ++-- yarn.lock | 24 +++++++++++++++--------- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 285fcd1..6080824 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -4,6 +4,7 @@ on: push: branches: - 'master' + - 'alpha' jobs: build: diff --git a/package.json b/package.json index 8639de4..a162cfd 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@aws-sdk/signature-v4": "^3.110.0", "@aws-sdk/url-parser": "^3.357.0", "@types/aws-lambda": "^8.10.101", - "axios": "^0.27.2", + "axios": "^0.28.0", "lodash": "^4.17.21", "nearley": "2", "url-parse": "^1.5.10", diff --git a/release.config.js b/release.config.js index 860c02a..aefad18 100644 --- a/release.config.js +++ b/release.config.js @@ -1,5 +1,5 @@ module.exports = { - branches: ['master'], + branches: ['master', { name: 'alpha', prerelease: true }], plugins: [ ['@semantic-release/commit-analyzer', { preset: 'conventionalcommits' }], '@semantic-release/npm', diff --git a/src/alpha.ts b/src/alpha.ts index 4f7329b..89f4ce7 100644 --- a/src/alpha.ts +++ b/src/alpha.ts @@ -75,12 +75,12 @@ export class Alpha extends Axios { if (castResp.status === 301 || castResp.status === 302) { if (maxRedirects === 0) { const request = castResp.request as InvocationRequest | HandlerRequest; - throw new RequestError('Exceeded maximum number of redirects.', castResp.config, request, response); + throw new RequestError('Exceeded maximum number of redirects.', castResp.config, request, castResp); } const redirect = cloneDeep(config); redirect.maxRedirects = maxRedirects - 1; - redirect.url = resolve(castResp.headers.location, castResp.config.url as string); + redirect.url = resolve(castResp.headers.location as string, castResp.config.url as string); return this.request(redirect); } diff --git a/yarn.lock b/yarn.lock index 999ab36..49af805 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2427,13 +2427,14 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ== -axios@^0.27.2: - version "0.27.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" - integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== +axios@^0.28.0: + version "0.28.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.28.0.tgz#801a4d991d0404961bccef46800e1170f8278c89" + integrity sha512-Tu7NYoGY4Yoc7I+Npf9HhUMtEEpV7ZiLH9yndTCoNhcpBH0kwcvFbzYN9/u5QKI5A6uefjsNNWaz5olJVYS62Q== dependencies: - follow-redirects "^1.14.9" + follow-redirects "^1.15.0" form-data "^4.0.0" + proxy-from-env "^1.1.0" babel-jest@^28.1.2: version "28.1.2" @@ -3534,10 +3535,10 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.1.1.tgz#c4b489e80096d9df1dfc97c79871aea7c617c469" integrity sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA== -follow-redirects@^1.14.9: - version "1.15.1" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5" - integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA== +follow-redirects@^1.15.0: + version "1.15.5" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020" + integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw== forever-agent@~0.6.1: version "0.6.1" @@ -5820,6 +5821,11 @@ propagate@^2.0.0: resolved "https://registry.yarnpkg.com/propagate/-/propagate-2.0.1.tgz#40cdedab18085c792334e64f0ac17256d38f9a45" integrity sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag== +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + psl@^1.1.28: version "1.8.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" From 80e2aef9c68c24ed587a91d4c3bccd7da20ce85b Mon Sep 17 00:00:00 2001 From: Alejandro Corredor Date: Mon, 26 Feb 2024 10:37:32 -0500 Subject: [PATCH 2/2] fix useFakeTimers call --- test/lambda-invocation.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/lambda-invocation.test.ts b/test/lambda-invocation.test.ts index ebb7a42..9a6a9b2 100644 --- a/test/lambda-invocation.test.ts +++ b/test/lambda-invocation.test.ts @@ -482,19 +482,19 @@ test('A configured timeout does not hinder normal lambda function invocation beh }); test('A configured timeout does not eat lambda function invocation errors', async () => { - jest.useFakeTimers(); + jest.useFakeTimers({ doNotFake: ['performance'] }); jest.spyOn(global, 'setTimeout'); jest.spyOn(global, 'clearTimeout'); delayedLambda(1, new Error('Other error')); const promise = ctx.alpha.get('/some/path', { Lambda: FakeLambda, timeout: 1000, - } as any as AxiosRequestConfig); + }); await expect(promise).rejects.toThrow('Other error'); - expect(ctx.abort).not.toBeCalled(); + expect(ctx.abort).not.toHaveBeenCalled(); - expect(setTimeout).toBeCalledTimes(1); - expect(clearTimeout).toBeCalledTimes(1); + expect(setTimeout).toHaveBeenCalledTimes(1); + expect(clearTimeout).toHaveBeenCalledTimes(1); }); test('lambda function invocation errors are re-thrown', async () => {