Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

deladels's avatar

Jobs failing on heroku but work correctly in local environment

I have some jobs set up to upload files to Digital Ocean Spaces in the background. What I noticed is that, the jobs run perfectly and the files are uploaded. But in production, I find out that the jobs are failing.

Any idea what could be going wrong? Or anyone experienced this before?

this is my job's handle method.

    public function handle()
    {
        Storage::disk('DO')->put(
            'uploads/business-registration/'.$this->certificateFileName,
            file_get_contents(
                public_path().'/storage/uploads/business-registration/'.$this->certificateFileName)
        );
        Storage::delete(public_path().'/storage/uploads/business-registration/'.$this->certificateFileName);
    }

this is my file upload service class with a handle function to process the file upload.

    public function powerPointFileUpload(Request $request) : string
    {
        $powerPointFile = $request->file('powerpoint');
        $powerPointFilename = $this->filename(
            $request->company_name, $powerPointFile
        );
        $powerPointFile->storeAs(
            'uploads/powerpoint', $powerPointFilename, 'public'
        );
        PowerPointFileUpload::dispatch($powerPointFilename);

        return $powerPointFilename;
    }

the controller method calling the file upload service

 public function store(StoreAgriBusinessInformationRequest $request, FileUploadService $fileUpload)
    {
        $uploadService = $fileUpload->handle($request);

        $registration = AgribusinessInformation::create($request->validated() + [
            'user_id' => Auth::user()->id
        ]);

        if (isset($uploadService['certificateFilename'])) {
            $registration->update([
                'attachments' => $uploadService['certificateFilename']
            ]);
        }
        
        session()->flash('success', 'Agribusiness Information Saved Successfully');
        return redirect()->route('personal-information.create');
    }

Also, I have the jobs table already migrated and changed the QUEUE_CONNECTION to database on heroku

0 likes
4 replies
deladels's avatar

Not error per se, the Jobs just failing.

2020-05-26T22:06:57.636246+00:00 app[worker.1]: [2020-05-26 22:06:57][126] Processing: App\Jobs\CertificateFileUpload
2020-05-26T22:06:57.760798+00:00 app[worker.1]: [2020-05-26 22:06:57][127] Processing: App\Jobs\CertificateFileUpload
2020-05-26T22:06:57.786592+00:00 app[worker.1]: [2020-05-26 22:06:57][128] Processing: App\Jobs\CertificateFileUpload
2020-05-26T22:06:57.797268+00:00 app[worker.1]: [2020-05-26 22:06:57][128] Failed:     App\Jobs\CertificateFileUpload

The above is from the logs. Unfortunately, it doesn't say much

deladels's avatar

Yes. And it's empty for no reason. And I have set up the config variables for that as well in heroku

QUEUE_FAILED_DRIVER=database

Please or to participate in this conversation.