earmsby's avatar

trouble with Filament exporter

I have created this exporter:

The queue worker is running and, in fact, I have a second exporter on a different model that is working fine. When I try to run the above export, it fails (no notification though). In the failed jobs table, I can see the exception:

TypeError: Cannot assign __PHP_Incomplete_Class to property Filament\Actions\Exports\Jobs\PrepareCsvExport::$exporter of type Filament\Actions\Exports\Exporter in /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Queue/SerializesModels.php:96
Stack trace:
#0 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Queue/SerializesModels.php(96): ReflectionProperty->setValue()
#1 [internal function]: Filament\Actions\Exports\Jobs\PrepareCsvExport->__unserialize()
#2 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(95): unserialize()
#3 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(62): Illuminate\Queue\CallQueuedHandler->getCommand()
#4 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(102): Illuminate\Queue\CallQueuedHandler->call()
#5 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(485): Illuminate\Queue\Jobs\Job->fire()
#6 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(435): Illuminate\Queue\Worker->process()
#7 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(201): Illuminate\Queue\Worker->runJob()
#8 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(148): Illuminate\Queue\Worker->daemon()
#9 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(131): Illuminate\Queue\Console\WorkCommand->runWorker()
#10 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
#11 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Container/Util.php(43): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#12 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(96): Illuminate\Container\Util::unwrapIfClosure()
#13 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\Container\BoundMethod::callBoundMethod()
#14 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Container/Container.php(799): Illuminate\Container\BoundMethod::call()
#15 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Console/Command.php(211): Illuminate\Container\Container->call()
#16 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/symfony/console/Command/Command.php(341): Illuminate\Console\Command->execute()
#17 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Console/Command.php(180): Symfony\Component\Console\Command\Command->run()
#18 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/symfony/console/Application.php(1102): Illuminate\Console\Command->run()
#19 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/symfony/console/Application.php(356): Symfony\Component\Console\Application->doRunCommand()
#20 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/symfony/console/Application.php(195): Symfony\Component\Console\Application->doRun()
#21 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(198): Symfony\Component\Console\Application->run()
#22 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1235): Illuminate\Foundation\Console\Kernel->handle()
#23 /home/forge/hildegard-dashboard.on-forge.com/releases/62766940/artisan(16): Illuminate\Foundation\Application->handleCommand()
#24 {main}

I can't quite figure out from this what the problem is. FWIW, I have restarted the queue multiple times and cleared the cache.

0 likes
5 replies
LaryAI's avatar
Level 58

The error you're seeing:

TypeError: Cannot assign __PHP_Incomplete_Class to property Filament\Actions\Exports\Jobs\PrepareCsvExport::$exporter of type Filament\Actions\Exports\Exporter

is caused during (un)serialization, which happens when the queued job is being processed. In a Laravel/Filament queued job, this usually means the PublicationExporter class is not available for the queue worker when it tries to handle the export.

This almost always points to a mismatch between your deployed code and what’s running in the worker, or an autoloading/class-loading issue.

Common causes and solutions:


1. Old queue worker process

Problem: The queue worker was started before you deployed the new exporter class, so it doesn’t have that class loaded.
Solution:

  • Whenever you deploy new code that adds classes used by queued jobs (like your new exporter), you MUST restart your queue worker(s):
php artisan queue:restart

You mentioned you “have restarted the queue,” but make absolutely sure that all queue workers were restarted after deploying the code which contains PublicationExporter.


2. Cache Issues (config, route, autoload...)

Problem: Old cached files are causing autoloading problems.
Solution:
Clear all the caches after deploying. Run:

php artisan config:clear
php artisan cache:clear
php artisan route:clear
composer dump-autoload

Restart the worker afterward, just to be sure.


3. Deployment/Rsync miss

Problem: The deployed server is missing the PublicationExporter file (bad deploy, or the file not included).
Solution:
Double-check, on the deployed server, that app/Filament/Exports/PublicationExporter.php exists, and is readable by PHP (permissions etc).


4. Namespace/Composer classmap autoload

Problem: The namespace or class name doesn’t match the file location, or composer’s autoload cache hasn’t updated.
Solution:

  • Ensure that PublicationExporter is in app/Filament/Exports/PublicationExporter.php and the namespace is App\Filament\Exports.
  • Run composer dump-autoload just to be sure.

5. Queue serialization compatibility

If you made changes to the exporter between starting the export and the job running, the serialized job may have been invalidated. If so, retrying with a fresh queued export (after confirming all previous steps) should now work.


TL;DR Solution Steps

Follow these steps in order:

  1. Double-check that PublicationExporter.php exists on your server, in the correct location, with correct namespace.
  2. Run on the server:
    php artisan config:clear
    php artisan cache:clear
    php artisan route:clear
    composer dump-autoload
    
  3. Restart ALL your queue workers:
    php artisan queue:restart
    
  4. Trigger the export again.

99% of the time, this will resolve the issue.


Why does a different exporter work?

If you have another exporter already working, it means its code was present before the current queue worker launched, or the worker hasn't been restarted since you added the new class. You need to re-load the worker so it can "see" the new class.


Let me know if this fixes it! If you still have trouble, please share:

  • Which queue driver you’re using (sync/redis/database/etc.)
  • How you run/deploy your queue workers (horizon, supervisor, etc.)
  • The result of running php artisan queue:restart and then retrying the export.
earmsby's avatar

Unfortunately, none of that solved the issue.

  1. I doubled-checked the namespace and the exporter exists on the server and the namespace is correct.
  2. I ran all four clearing commands
  3. I ran queue:restart and then queue:work to restart the worker

I still got the same error in the failed_jobs table.

I am only running this on my localhost at the moment (using Herd). The env file is set to: QUEUE_CONNECTION=database I am running the queue worker manually via the command line with queue:work.

Anything else to try?

earmsby's avatar

I just noticed something subtle in the error message that I didn't notice at first:

TypeError: Cannot assign __PHP_Incomplete_Class to property Filament\Actions\Exports\Jobs\PrepareCsvExport::$exporter of type Filament\Actions\Exports\Exporter in /home/forge/hildegard-dashboard.on-forge.com

The error seems to be referring to my project on the production server: "/home/forge/hildegard-dashboard.on-forge.com" even though I'm testing this exporter on my local Herd site.

Why would it be doing that?

earmsby's avatar

I decided to deploy the exporter to the production server on Forge. Did that and then ran the export on the production server and worked fine. I might see if, having deployed it, it now also works on local Herd.

Please or to participate in this conversation.