spatie / ray

Debug with Ray to fix problems faster
https://myray.app
MIT License
568 stars 102 forks source link

Call to undefined method ::payload() #586

Closed heshamabdallah closed 2 years ago

heshamabdallah commented 2 years ago

Describe the bug I have the same issue described here #319

Versions spatie/laravel-ray version: 1.26.1 spatie/ray version: 1.30.3 PHP version: 8.0.12 Laravel version: ^8.54

My Job

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class UnzipProductStandingDataFileToCsvFiles implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Update type.
     *
     * @var string full|delta
     */
    protected $updateType;

    /**
     * Create a new job instance.
     *
     * @param  string $updateType
     * @return void
     */
    public function __construct(string $updateType)
    {
        $this->updateType = $updateType;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        error_log('UnzipProductStandingDataFileToCsvFiles is dispatched!');
    }
}

To Reproduce

UnzipProductStandingDataFileToCsvFiles::dispatch('full');

Screenshots Screenshot from 2021-11-02 01-53-42

Additional context I opened vendor/spatie/laravel-ray/src/Payloads/JobEventPayload.php and dumped the job methods and I can't find the payload method.. it seems JobEventPayload is missing a trait or something.

dd(get_class_methods($event->job));

Screenshot from 2021-11-02 01-55-53

wit3 commented 2 years ago

Same error, only if i set

# SEND_JOBS_TO_RAY=true


Error
Call to undefined method Illuminate\Broadcasting\BroadcastEvent::payload()

From

vendor/spatie/laravel-ray/src/Payloads/JobEventPayload.php:23

    public function __construct(object $event)

    {

        $this->event = $event;

        $this->job = unserialize($event->job->payload()['data']['command']);

        if (property_exists($event, 'exception')) {

            $this->exception = $event->exception ?? null;

        }

    }
AdrianMrn commented 2 years ago

I'm going to close this issue because it's been inactive for a while. Let me know if you still need help with this problem!

stein-j commented 2 years ago

Same issue here.

Steps to reproduce are pretty simple (In a Laravel environment):

1) Create an empty job php artisan make:job RayPayloadIssueJob 2) Set send_jobs_to_ray to true 3) Make sure you have a queue set up and are not using the sync connection/driver (I am using the database connection) 3) Call dispatch(new RayPayloadIssueJob()); anywhere and the error should pop-up

freekmurze commented 2 years ago

@stein-j if you also know the fix, feel free to PR it 👍

stein-j commented 2 years ago

I didn't know the fix, after checking the source code and distracting myself from what I was suppose to do today, here's a PR aha 🤫 https://github.com/spatie/laravel-ray/pull/245