-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Node compatibility issue with handling multipart/form-data files #20284
Comments
I can be more specific. I was testing uploading PNG files and then trying to read them back in the browser, and this is how I was noticing the data corruption issues, where the data in some of the files gets jumbled up and is unrecognizable as an image file. The chance of each file being corrupted also appears to be correlated to its file size. For example, a bunch (15+) of images at 305B each had no corruptions. A bunch of 3.5KB images had only one corruption, and a bunch of large 2.1MB images had every image except for one corrupted. |
Updating file size to 5MB did the trick Reproduction (Windows 10):
Note all hashes match
Note second hash mismatch Removing This is my analysis so far
cc @bartlomieju This is a reproducible data corruption issue |
Thanks for the report folks. We fixed a big bug in |
@bartlomieju Yes, also occurs with |
Thanks, we'll look into that! |
Any updates on this @bartlomieju? Also tried this with v1.37.2. |
Update: I haven't had issues with this since running newer versions of Deno (v1.38.3+). Seems like it got resolved, just wanted to make sure it was intentional before closing the issue. |
I tested my repro from #20284 (comment) with 1.40.2 and it still occurs. However the 'happy path' when fs.writev is available seems to work ok. .e.g. Ok: Potential corruption: |
@CoenraadS I couldn't reproduce the data corruption using the repro.zip (main.js) with the latest Deno on Windows Server 2022 and MacOS 13.3. Can you still reproduce the error with the latest Deno? If you still can, how likely does it happen on your end? |
A createWriteStream issue has just been fixed in node.js, but it still exists in deno. Repro: import fs from 'node:fs';
import process from 'node:process';
const w = fs.createWriteStream('file.txt');
w.on('open', () => {
w.write('hello');
process.nextTick(() => {
w.write('world');
w.end();
});
});
w.on('close', () => {
console.log(fs.readFileSync('file.txt', 'utf8'));
}); deno v1.42.0:
|
It still occurs for me, sending 2 files I think isn't enough, try bumping it up to a higher number. Usually within the first 10 I get a hash error. I will reiterate though that the default happy path works ok, only when removing fs.writev does it occur (while node passes), which I only did while experimenting with creating a repro, not using this in real code. Ok: Potential corruption: |
@CoenraadS Thanks. Now I'm able to reproduce the issue consistently with ~20 iterative checks on macOS.
I'll check it in more details soon |
@dy-dx Thanks for the input! |
This PR follows this fix (nodejs/node#52005) in Node.js. Stream's construct callback happens one tick earlier by this change, and it prevents the reordering of the first few chunks in `node:stream.Writable` closes #20284
This PR follows this fix (nodejs/node#52005) in Node.js. Stream's construct callback happens one tick earlier by this change, and it prevents the reordering of the first few chunks in `node:stream.Writable` closes #20284
I've been noticing file corruption issues while letting the
koa-body
library handle multiple files withmultipart/form-data
requests. In the Deno server code where I'm using the npm modules some files get corrupted during the save while with NodeJS the files are saved fine. I'm using Deno v1.36.3, and the issue can reliably happen as long as you're selecting 20+ images on the browser as a multi-file upload to the server.Client code that sends the request:
Server code in Deno:
Server code in NodeJS
The text was updated successfully, but these errors were encountered: