It looks like multer doesn't call sync or datasync when files are closed, which can lead to data corruption.
|
var outStream = fs.createWriteStream(finalPath) |
NodeJS does support a flush option which will ensure data is flushed to disk before closing the file. It would be great if multer could add an option to set this.
https://nodejs.org/api/fs.html#filehandlecreatewritestreamoptions
Environment information
Version:
v2.1.1
Platform:
Linux
Node.js version:
v25.8.1
Any other relevant information:
What steps will reproduce the bug?
Upload a file, and observe that in certain conditions the handler may say that the upload has completed, but in reality the data has not been written to disk and so the file is either corrupt or lost.
It looks like multer doesn't call
syncordatasyncwhen files are closed, which can lead to data corruption.multer/storage/disk.js
Line 37 in 368c8a1
NodeJS does support a
flushoption which will ensure data is flushed to disk before closing the file. It would be great if multer could add an option to set this.https://nodejs.org/api/fs.html#filehandlecreatewritestreamoptions
Environment information
Version:
v2.1.1
Platform:
Linux
Node.js version:
v25.8.1
Any other relevant information:
What steps will reproduce the bug?
Upload a file, and observe that in certain conditions the handler may say that the upload has completed, but in reality the data has not been written to disk and so the file is either corrupt or lost.