Comments (18)
Hi @Mar-Ser I know this is an old issue, but I was able to track this down to a regression from the following commit in Node.js: nodejs/node@369b7c2 . This affects the async await function on streams in general. It seems to behave differently based on internal timings of events within Node.js, which is why it sometimes works, but mostly does not work. The good news is that it seems to not affect Node.js 13+, even this it is landed there. It was backported to Node.js 12.16.0 and likely is conflicting with some other behavior that is in Node.js 12 that is not in 13. Unfortunately it does not seem there is any possible way to fix it from this module.
from multiparty.
Thank you, I will take a look. It looks like in 12.16.0 there were a bunch of changes around async iteration on event emitters, which could have introduced this change of behavior. In your example above, you are actually iterating over a built-in Node.js event emitter: a Passthrough stream.
from multiparty.
Taking a look into it, I'm not able to reproduce with 2.18.3. When copying and pasting your exact program and following the instructions on 12.18.3, this is my console output:
$ node -v
v12.18.3
$ node index.js
1
2
4 Error: 1
at Server.<anonymous> (C:\Users\dougw\GitHub\multiparty-231\index.js:13:15)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
5
from multiparty.
from multiparty.
Strange. I tried with various Node.js versions and all of them show all the numbers. Without the ability to reproduce the issue, there is nothing I can debug. Can you try following your steps above on a different machine just to see if it reproduces or not so we can narrow down which of our machines is the outlier?
from multiparty.
This is not related to my machine because in first time it was failed on CI... We (I and my colleague) spent a day trying to debug it. So, it already was reproduced in three different environments...
from multiparty.
Anyway, I will try to run this code on my home machine.
from multiparty.
Hm, strange. After I sent that I tried on a laptop, which has never even had Node.js on it before, and worked just fine. Perhaps the issue is within some steps not provided above. I tried with Chrome and the file I uploaded was the index.js file itself. If you upload the index.js file through Chrome with the server, does it still happen?
from multiparty.
On home PC a result is the same:
$ node -v
v12.18.3
$ node index.js
1
2
Also, I tried to upload the index.js itself and the result also the same. And in all cases, I used Chrome, exclude CI.
from multiparty.
Strange. There has to be something different between our methods... 🤔 . Maybe we need to wait for another member to come by and see if they can reproduce and debug through it. You're also always welcome to make a pull request if you can determine the issue, or even add this as a test to our test suite and open a PR with that added (it doesn't matter if it fails, etc.: it'll be a clean environment that gives us both a place to see it).
from multiparty.
Here is another thing to try: I was going to make a reproduction with the PassThrough stream without multiparty, to determine if it was a Node.js issue or multiparty, but since I couldn't reproduce the issue, I am not able to verify if this demonstrates it or not as a reduced test case. Does this experience issues on your setup?
var stream = require('stream');
const pts = new stream.PassThrough();
const run = async () => {
try {
console.log(1);
for await (const data of pts) {
console.log(2);
throw new Error('1');
}
console.log(3);
} catch(err) {
console.log(4, err);
}
console.log(5);
};
pts.write('test1');
run()
.then(() => { console.log('done!'); })
.catch((e) => { console.error(e); });
from multiparty.
No. This code passed.
from multiparty.
Darn. So can you make a pull request to add this issue to our test suite to get it reproducing on our CI?
from multiparty.
Ok!
from multiparty.
Pipeline for 12.18.3 failed as expected by timeout. 10 and 14 passed. The old versions don't support for await
. Going to exclude them later for this test.
from multiparty.
Our thoughts:
After throw
or break
, it exits from the for await
cycle. But before exit, it tries to destroy the stream and waits until it happens. But something is going wrong, and it is never happening...
from multiparty.
Yea, I agree. It seems to be getting stuck in the return()
of the async iterater for some reason I'm trying to determine.
from multiparty.
@dougwilson Thank you!
from multiparty.
Related Issues (20)
- unhandled exception on unclear conditions HOT 6
- part "index" or count? HOT 14
- In request with both text and file, byteCount of the file part is incorrect HOT 4
- Getting writeAfterEnd issue on 2nd upload. The program is shared below. HOT 2
- Parsing an multipart of form-data in README example, but files and fields are undefined HOT 2
- form-data file is empty with node version 14.1.0 HOT 9
- TypeScript version of multiparty HOT 1
- form.on('close' event get fired before all form.on('part' are done. NodeJS 14 HOT 3
- form.parse callback prevents form.on('part') from running HOT 2
- Update to mkdirp ≥ 1 HOT 1
- Update mkdirp dev dependency HOT 1
- Listen for close event on part HOT 1
- os.tmpDir seems to be incompatible with Windows HOT 2
- files var in form.parse does not have all the files uploaded HOT 12
- Unable to detect part correctly if content-disposition name or filename headers do not contain double-quotes. HOT 4
- Readme example uses "close" instead of "finish" HOT 4
- Content type does not support application/json HOT 1
- Unicode filenames need to be decoded. HOT 1
- How to parse form-data from RESPONSE not REQUEST?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from multiparty.