Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak when I get the error "Request body larger than maxBodyLength limit" #3461

Closed
jose-lopes opened this issue Dec 7, 2020 · 3 comments · Fixed by #3771
Closed

Memory leak when I get the error "Request body larger than maxBodyLength limit" #3461

jose-lopes opened this issue Dec 7, 2020 · 3 comments · Fixed by #3771
Projects
Milestone

Comments

@jose-lopes
Copy link

Describe the bug

I observe a memory leak when I request a file and pipe to another request and I get the error "Request body larger than maxBodyLength limit"

To Reproduce

To reproduce the problem, I request a file of 20MB and pipe to another request.
Bellow there a sample code:

const optsGetFile = {
  method: "get",
  url: "http://localhost:7001/download",
  responseType: "stream",
};
const optsUploadFile = {
  method: "post",
  url: "http://localhost:7001/upload",
};

axios(optsGetFile)
  .then(({ headers, data }) => {
    return axios(_.assign(optsUploadFile, { data, headers }));
  })

The entire test code is present at https://github.com/jose-lopes/test_axios .
Next I will describe the environment that I setup to reproduce the problem.

  • Start fake server. (This program serve /upload and /download (20MB) requests)
node test_fakeserver.js
  • Start test server and monitor memory with memory-profiler. (This program serve /record request, which it get /download and post to /upload)
mprof run node test.js
  • execute 20 /record requests with interval of 30 seconds
for test in $(seq 1 20); do curl -X POST localhost:7000/record; sleep 30; done
  • Stop test server and execute mprof plot to check memory behavior.
mprof plot

Expected behavior

I expected no memory leak even when we got the error "Request body larger than maxBodyLength limit".
I executed again the test server with option maxBodyLength: 3010241024 and I got no memory leak.

Environment

  • Axios Version: 0.21.0
  • Node.js Version: v14.15.0
  • OS: Arch Linux

Additional context/Screenshots

Graph when I execute to reproduce:
Test Result

@isvidler
Copy link

isvidler commented Mar 9, 2021

Has a solution been found or implemented? I'm experience the same error when using Axios (Node) with FormData (https://github.com/form-data/form-data).

@jasonsaayman
Copy link
Member

Please check if this has been fixed with #3694

@misos1
Copy link

misos1 commented Apr 28, 2021

This is duplicate of #3460.

@jasonsaayman jasonsaayman linked a pull request Apr 29, 2021 that will close this issue
@jasonsaayman jasonsaayman added this to the v0.22.0 milestone Apr 29, 2021
@jasonsaayman jasonsaayman added this to To do in v0.22.0 via automation Apr 29, 2021
v0.22.0 automation moved this from To do to Done Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v0.22.0
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants