Skip to content

Commit

Permalink
perf: use maxContentLength -1 instead of Infinity (#158)
Browse files Browse the repository at this point in the history
The purpose of `Infinity` here is to have no limit, but as per axios/axios#2829 the check is enabled for all values > -1 and the check introduces a performance issue. Changing the value to `-1` prevents the check being enabled.
  • Loading branch information
ricellis authored Aug 31, 2021
1 parent 64fefb0 commit adbbb3b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/request-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class RequestWrapper {
// to 'application/x-www-form-urlencoded'. This causes problems, so overriding the
// defaults here
const axiosConfig: AxiosRequestConfig = {
maxContentLength: Infinity,
maxContentLength: -1,
maxBodyLength: Infinity,
headers: {
post: {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/request-wrapper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('RequestWrapper constructor', () => {
// the constructor puts together a config object and creates the
// axios instance with it
const createdAxiosConfig = axios.default.create.mock.calls[0][0];
expect(createdAxiosConfig.maxContentLength).toBe(Infinity);
expect(createdAxiosConfig.maxContentLength).toBe(-1);
expect(createdAxiosConfig.maxBodyLength).toBe(Infinity);
expect(createdAxiosConfig.headers).toBeDefined();
expect(createdAxiosConfig.headers.post).toBeDefined();
Expand Down

0 comments on commit adbbb3b

Please sign in to comment.