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

form-data file is empty with node version 14.1.0 #226

Closed
chwo opened this issue May 4, 2020 · 9 comments
Closed

form-data file is empty with node version 14.1.0 #226

chwo opened this issue May 4, 2020 · 9 comments
Assignees
Labels

Comments

@chwo
Copy link

chwo commented May 4, 2020

Description

I am doing a multipart/form-data POST Request with fields and a file in the body.

When I try to access the file in the form.parse function, the files property is empty.

const form = new multiparty.Form();
form.parse(req, (error, fields, files) => {
    console.log(files) // -> is empty: {}
});

I tried debugging it and noticed that

self.on('close', function() {

is called before

self.on('file', function(name, file) {

This order occurs with node version 14.1.0 whereas for example with node version 12.0.0 the order is the opposite and the files property contains the file.

Environment

  • multiparty version 4.2.1
  • node version 14.1.0
@dougwilson dougwilson self-assigned this May 5, 2020
@dougwilson dougwilson added the bug label May 5, 2020
@dougwilson
Copy link
Contributor

Hi @chwo thank you for the report. It is indeed a bug due to some streams changes in Node.js 14. I am working to get it all fixed up. You can look though expressjs/connect-multiparty#29 if you wanted to know about some of the background, but otherwise I'll use this issue as the tracker for the Node.js 14 fix in multiparty itself 👍

@hkumar4
Copy link

hkumar4 commented Jul 7, 2020

Hi, Can someone please update when this issue would be fixed? I see that the form.on('close') fires twice since node 14. Once with empty files and then with files populated. Thank you for looking into this.

dougwilson added a commit that referenced this issue Jul 8, 2020
@barisusakli
Copy link

Hi @dougwilson, looks like you fixed this, any eta on a new release for this and connect-multiparty?

@dougwilson
Copy link
Contributor

Hi @barisusakli indeed, I fixed both issues with the Node.js changes: max size limit broken and files empty. The first change was an issue with a dependency being broken and it looks like it will just never be fixed, so that was a bit more involved change to test. I think it is working well, but if not we'll just field any reported bugs. I'm going to land them here now, sorry for the delay.

@dougwilson
Copy link
Contributor

The fix is merged into master. Please feel free to test ahead of time. I try not to release and then go to sleep, so will release first thing in the morning.

@barisusakli
Copy link

@dougwilson from my testing our upload tests pass by using the latest code from multiparty with node 14.6.0 and connect-multiparty 2.2.0

@dougwilson
Copy link
Contributor

Published as patch version 4.2.2

@barisusakli
Copy link

👍 waiting on connect-multiparty

@dougwilson
Copy link
Contributor

@barisusakli it is picked up automatically as the package.json is ~4.2.1

aduvarov added a commit to aduvarov/web-development-with-node-and-express-2e that referenced this issue Dec 15, 2021
streams changes in Node.js 14
dougwilson commented on 28 Jul 2020
Published as patch version 4.2.2
pillarjs/multiparty#226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants