FileUpload bug - Some files a are missing after uploaded.
When I try to upload multiple files, after the uploading couple of files are missing. this incident is absolutely random. In the below picture I have tried to upload 5 files in two sections. All are same files. In applicationFiles(top one) all 5 files were uploaded, but in the result_files section one file is missing. I have also attache the screen shot of the folder section. The leftover file is in livewire-tmp folder.
47 Replies
Hi, I've got the same problem, I've an action for the multiple upload, and when I put the debugger in the foreach in the code below, the $data array already is missing some files...
Also no errors are reported in the storage/log/laravel.log file
Anything in the filenames that could be confusing the array into thinking one complete filename is actually 2 or more (incomplete) filenames.?
Is it always the same files missing ?
Hi, the files have all different names, and the missing ones changes from one try to the other, I'm attaching a couple screenshots
in this case is the file with name .._06... missing
*sorry ..._04... is missing
I've re-ran it and now the ..._00.. is missing
other times more than one file is missing, sometimes all files are uploaded...
how about if you try to upload about 4 files same time ? still missing files ?
Hi, I've just tried uploading only 4 files, the first two times it uploaded all of them, the third time one was missing
you use valet or something else ?
this is with sail on linux, but the same happens to other devs on windows and on the staging server, running linux with PHP-fpm behind nginx (in docker)
php-fpm log not show any error ?
I haven't checked on the server (but it's in production as far as APP_ENV is concerned), but on my PC it appears the missing files are never received within the array of uploaded $data in the action, I'll expand the code below to have a better context, but with the debugger, in the foreach line $data is already missing the files
I'll try on the server now
if you're doing a four-file transfer, for example, so. are you able to track which file drops out of them and is it the last file whose upload is complete
As these example files have 00, 01, 02, ... in their filename, in the upload modal it processes two of them at a time, starting from the first two. When they are at 100% it starts with the next two and so on. They are in alphabetical order, so no it's not always the last file to be uploaded that is skipped. Also, with multiple uploads of the same files the missing files changes between tries
that i mean.. file upload size or request time out possible php issue
then that is randomized
but that issue found in php-fpm log
(Oh, ok, maybe I need to check in the broser develop tabs then, I'll check it)
meanwhile on the server I've run a few tests, the first two uploads worked with all files there, the third one was missing a file but there isn't any log on the php-fpm side, nor in the storage/log/laravel.log file
->action(function (array $data, $record) {
Notification::make()
->title(__('The images are being transformed, soon you will be able to see them'))
->info()
->send();
foreach ($data['images'] as $fileName){
ImageService::handleImageUpload($fileName, $record);
}
print me dd($data) before notification
print me dd($data) before notification
Here it's missing 2 files, the 01 and the 05
ok then try files where size is slow example something test png images
ok, even though I should have set it so that 3.5 Mb shouldn't be a problem, anyway I'm creating the files and testing it, thankds
I've created 9 very small (1000x1000 px) images, around 1Kb each, and tried uploading them twice, each time it was missing some files
these are all identical files (I've created an image with GIMP and copied it over to all these new files
images found in livewire-tmp folder ?
and you use php8.2 or 8.1 ?
one time it was missing the 02 and the 05, the other one 02 and 06
I'm using php 8.2 in sail
let me check if something remains in the livewire-tmp dir, I'm emptying it now and trying uploading the same files again
yes the missing files are still in the livewire-tmp dir
can you show screenshot browser dev tools where show upload request... i think you got error upload-file request
this is when dropping the file in the fileupload zone
this was a 9-file upload
yeah and 7 complete
yes
I've split the dev bar screenshot in two files, but it was all together in the browser
yeah but i found only 7 upload-file request
that move files to livewire-tmp to correct destination folder
Actually they are 9, two in the first screenshot, 7 in the second one
they do not overlap
(the screenshots I mean)
true..
hmm livewire version ?
I've ran composer update last friday I think, anyway let me check
yes
livewire/livewire 3.5.6
do it this php artisan livewire:publish --assets and then again
and php artisan optimize:clear
ok... I didn't publish the livewire assets before, I'm trying
with the assets published
(I'm not sure what's the idea behind it, TBH :))
anyway, two files are missing after publishing the assets and optimize:clear
no luck...
I've searched across the internet and other people have reported similar problems in the past, it seems something in the FileUpload filament component...
i'm not sure this issue is FileUpload because i just test about 10 times and i have work fine
no missing files
ah
hmm your destination is local or s3 ?
local
try to use ->moveFiles()?
hmm try to add fileupload ->image() that is only difference my code
ah hehehaha that is true... i have this too 😄
I'm trying the two things now, thanks
with just ->image() the problem persists (but once I'm there, I'll leave it in since these must be images anyway :))
even with both moveFiles and image the problem remains...
I'll need to try it out in a new project to isolate it at this point...
I've found the problem... the resource has a relationManager with the Resources that are created when uploading a file (in the foreach in the code above, we create a new instance of a Model, and connect the file with that Model).
If the table method in the relation manager has a ->poll('5s') (for instance) then the problem arises!
I've created a test project https://github.com/danilogiacomi/filamentFileUploadProblem/
GitHub
GitHub - danilogiacomi/filamentFileUploadProblem
Contribute to danilogiacomi/filamentFileUploadProblem development by creating an account on GitHub.
if you use it as it is, you will (randomly) find the problem discussed here
whereas if (in app/Filament/Resources/OrderResource/RelationManagers/FilesRelationManager.php at line 49) you comment out the ->poll('5s') line, then the problem isn't occurring anymore
it's crazy, I'll try to contact the filament devs
ah i'm never use ->pool() a completely useless feature in my opinion, it causes unnecessary queries that strain the server
you are probably right, but in this case it's perfect as we upload multiple image files which need to be processed (via some jobs) and therefore we can watch them automatically update in the table below our resource. I don't know if there's a better way to do so, in any case I've submitted the issue to the filament github repo
(I've actually added a comment, with the link to my test repo, to an existing issue related to missing files from multiple fileUpload)
GitHub
FileUpload: Some files are missing when uploading multiple files · ...
Package filament/filament Package Version 3 Laravel Version 11 Livewire Version V3 PHP Version php 8 Problem description When I upload multiple files, some of the files are missing. Expected behavi...
can you test if you increase pool example 15sec ? how about then still files lost ?
Hi I've just tried it and still it was missing a couple of files, out of the 32 I've uploaded, feel free to tinker around with the code in the repo, the README should have enough info for testing the whole thing