Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class "Spatie\Ray\Payloads\ApplicationLogPayload" not found #237

Closed
domthomas-dev opened this issue Jan 11, 2022 · 80 comments
Closed

Class "Spatie\Ray\Payloads\ApplicationLogPayload" not found #237

domthomas-dev opened this issue Jan 11, 2022 · 80 comments
Assignees

Comments

@domthomas-dev
Copy link

Describe the bug
The class "Spatie\Ray\Payloads\ApplicationLogPayload" not found

  • spatie/ray package version: 1.32.3
  • spatie/laravel-ray package version (if applicable): 1.27.2

PHP version: 8.1.0
Laravel version: 8.78.1

Capture d’écran de 2022-01-11 15-24-52

NB : I see this site, but ..... https://php-download.com/package/spatie/laravel-ray/file/src/Watchers/ApplicationLogWatcher.php

@voicecode-bv
Copy link

voicecode-bv commented Jan 12, 2022

Same issue here using:

  • PHP 8.1
  • Laravel 8.78
  • Ray 1.19 (application)
  • spatie/laravel-ray package 1.28

@rafaellaurindo
Copy link

Same issue here using:

  • PHP 8.1
  • Laravel 8.78.1
  • spatie/laravel-ray package 1.28.0

@telkins
Copy link

telkins commented Jan 14, 2022

I'm getting the same:

  • PHP 8.1
  • laravel/framework v8.79.0
  • spatie/ray 1.33.0
  • spatie/laravel-ray 1.29.0

@freekmurze
Copy link
Member

I'm having a hard time reproducing this. How can I trigger this error in a vanilla Laravel app?

@telkins
Copy link

telkins commented Jan 16, 2022

I'm having a hard time reproducing this. How can I trigger this error in a vanilla Laravel app?

I haven't tried with a brand-new Laravel app, but I think I've experienced it on two different apps that I'm working on.

I'm pretty sure I've seen it off and on over the last several weeks and it seemed to have something to do with when I'd try to log something using the standard Laravel log facade. (Take that with a grain of salt because my memory's a little blurry...but I remember being frustrated that I couldn't use the log for troubleshooting.)

Anyway, I'll try to take some time next time it happens to see if I can let you know more.

In one case, it's a L8 project that is pushing two years old with all sorts of stuff going on. In the other, it's another L8 app that is only a month or two old which uses Jetstream...not much else. But, both use Filament Admin...which may or may not be related. I'd love to hear if any of the others are also using that package.

@telkins
Copy link

telkins commented Jan 17, 2022

Back on the "new" project and I can replicate it very easy. There's a bit of code that I'm trying to troubleshoot. I was enabling and then dumping the query log around a search query and I get the error.

When I have this, I get the ApplicationLogPayload class not found exception:

    \Illuminate\Support\Facades\Log::debug('test');

(Of course, I was trying to dump the query log, but I dropped that to see if it made any difference.)

When I comment that line out, then it works fine:

    // \Illuminate\Support\Facades\Log::debug('test');

The app, as mentioned earlier, is a Laravel 8 app with Jetstream (livewire, no teams), and Filament Admin. It's basically a Filament Admin app.

The other app that I work on where I've observed this also uses Filament Admin and it's only a recent addition. I don't think I noticed this error before Filament Admin was introduced...which leads me to believe that it's somehow related to that package.

I'm not sure if this helps or not. Please let me know what else I can help with. In the meantime, if I have time to dig a little and/or come across something, I'll come back here to post/share. 🤓

@voicecode-bv
Copy link

@telkins thanks for the research, I don't think it's really something with Filament alone as I don't use that in any of my projects, but do get the error. I had to remove ray from 4 projects already as developing became a bit of a pain. I'm searching for examples too. When I find something, I'll definitely post it here.

@telkins
Copy link

telkins commented Jan 17, 2022

@telkins thanks for the research, I don't think it's really something with Filament alone as I don't use that in any of my projects, but do get the error. I had to remove ray from 4 projects already as developing became a bit of a pain. I'm searching for examples too. When I find something, I'll definitely post it here.

Thx. Nice to know it doesn't have anything to do with Filament Admin. 😅

How do you get rid of ray, though? I'm not requiring it explicitly.

I'll add that it seems to occur whenever there's an error/exception. This might help me going forward....at least until the issues are resolved or I figure out how to remove it. 🤓

@samuelcecilio
Copy link

@telkins run composer why spatie/laravel-ray and remove all packages that use laravel-ray. It was the fastest alternative I found until the issue is resolved.

@voicecode-bv
Copy link

One thing I noticed is that I was using a really old config file, as I was not really aware of its existence because of the unusual config file location. I don't know wether or not this was causing the issue, but I'm installing the package to my projects again to see if I run into some trouble the next couple of days.

@freekmurze
Copy link
Member

@voicecode-bv Thanks, being able to reproduce this error would greatly help us to fix it.

@SimonJulian
Copy link

Hi,

We've noticed the issue ourselves on a couple of production boxes over a couple of versions, in both cases the laravel-ray package was included in require-dev if it helps narrow anything done.

Versions were/are

  • PHP 8.1
  • laravel/framework 8.77.1 and 8.79.0
  • spatie/ray 1.32.2 and 1.33.0
  • spatie/laravel-ray 1.27.2 and 1.29.0

In our case the only difference between our local config file and the current one in this package are we are missing the following three keys, send_duplicate_queries_to_ray, send_slow_queries_to_ray and send_http_client_requests_to_ray and our host default is falling back to the default homestead ip as that's how we published it.

Thanks,

@voicecode-bv
Copy link

voicecode-bv commented Jan 17, 2022

@freekmurze Just got one in a form request. Stripped it down a bit to narrow things down.

Good to know:

  • There's no ray config file published in this project
  • Tried spatie/laravel-ray version 1.28 and 1.29 in both require-dev and require object of composer.json
  • PHP 8.1.1
  • Laravel 8.79.0
<?php

namespace App\Http\Requests\Api\V1\OCPI;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;

class UpdateLocationRequest extends FormRequest
{
    // Authorize request.
    public function authorize(): bool
    {
        return true;
    }

    // Validation rules.
    public function rules() : array
    {
        return [
           //
        ];
    }

    // Handle request.
    public function handle()
    {
        Log::info('Location put: '.json_encode(request()->all()));
    }
}

@telkins
Copy link

telkins commented Jan 17, 2022

    // Handle request.
    public function handle()
    {
        Log::info('Location put: '.json_encode(request()->all()));
    }

This seems to line up with some of the experiences I described earlier in this thread, which was that it would seem to happen when I was simply trying to log something...at least some of the time.

But, I don't think that it's always happening when I try to log something. 😕

@dejagersh
Copy link

dejagersh commented Jan 18, 2022

Some findings:

  • Renaming the file and class to ApplicationLogPayload2 in the vendor/ directory makes it work again.
  • Replacing $payload = new ApplicationLogPayload($message->message); with $payload = new BoolPayload(true); works as well.

Edit: Ok I got something else interesting: I am using Valet and it does not give this error when I run through php artisan serve.

Edit: restarting Valet solves it.

Edit: It does not only occur on Valet, because I got this error on prod where I accidentally also included dev dependencies.

P.S. I am on:

"spatie/laravel-ray": "1.29.0"
PHP 8.1.0
Laravel 8.79.0

@keizah7
Copy link

keizah7 commented Jan 19, 2022

Laravel Framework 8.80.0
PHP 8.1.1
Ray Version 1.19.0 (1.19.0)
Composer version 2.2.2

same problem

[2022-01-19 11:37:58] local.ERROR: Class "Spatie\Ray\Payloads\ApplicationLogPayload" not found {"exception":"[object] (Error(code: 0): Class \"Spatie\\Ray\\Payloads\\ApplicationLogPayload\" not found at /Users/arturas/***/ure/vendor/spatie/laravel-ray/src/Watchers/ApplicationLogWatcher.php:24)
[stacktrace]
#0 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(404): Spatie\\LaravelRay\\Watchers\\ApplicationLogWatcher->Spatie\\LaravelRay\\Watchers\\{closure}(Object(Illuminate\\Log\\Events\\MessageLogged))
#1 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Log\\\\...', Array)
#2 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Log/Logger.php(245): Illuminate\\Events\\Dispatcher->dispatch('Illuminate\\\\Log\\\\...')
#3 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Log/Logger.php(186): Illuminate\\Log\\Logger->fireLogEvent('warning', 'Return type of ...', Array)
#4 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Log/Logger.php(106): Illuminate\\Log\\Logger->writeLog('warning', 'Return type of ...', Array)
#5 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(102): Illuminate\\Log\\Logger->warning('Return type of ...')
#6 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Support/helpers.php(377): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}(Object(Illuminate\\Log\\Logger))
#7 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(105): with(Object(Illuminate\\Log\\Logger), Object(Closure))
#8 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(72): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleDeprecation('Return type of ...', '/Users/arturas/...', 146)
#9 /Users/arturas/***/ure/vendor/composer/ClassLoader.php(571): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8192, 'Return type of ...', '/Users/arturas/...', 146)
#10 /Users/arturas/***/ure/vendor/composer/ClassLoader.php(571): include('/Users/arturas/...')
#11 /Users/arturas/***/ure/vendor/composer/ClassLoader.php(428): Composer\\Autoload\\includeFile('/Users/arturas/...')
#12 /Users/arturas/***/ure/vendor/spatie/laravel-ray/src/Watchers/ApplicationLogWatcher.php(24): Composer\\Autoload\\ClassLoader->loadClass('Spatie\\\\Ray\\\\Payl...')
#13 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(404): Spatie\\LaravelRay\\Watchers\\ApplicationLogWatcher->Spatie\\LaravelRay\\Watchers\\{closure}(Object(Illuminate\\Log\\Events\\MessageLogged))
#14 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Log\\\\...', Array)
#15 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Log/Logger.php(245): Illuminate\\Events\\Dispatcher->dispatch('Illuminate\\\\Log\\\\...')
#16 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Log/Logger.php(186): Illuminate\\Log\\Logger->fireLogEvent('error', 'Unsupported ope...', Array)
#17 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Log/Logger.php(94): Illuminate\\Log\\Logger->writeLog('error', 'Unsupported ope...', Array)
#18 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\\Log\\Logger->error('Unsupported ope...', Array)
#19 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\\Log\\LogManager->error('Unsupported ope...', Array)
#20 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(49): Illuminate\\Foundation\\Exceptions\\Handler->report(Object(TypeError))
#21 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(130): Illuminate\\Routing\\Pipeline->handleException(Object(Illuminate\\Http\\Request), Object(TypeError))
#22 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#23 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#24 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#28 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#29 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest(Object(Illuminate\\Http\\Request), Object(Illuminate\\Session\\Store), Object(Closure))
#30 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#33 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#34 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Routing/Router.php(723): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#37 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Routing/Router.php(698): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#38 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#39 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Routing/Router.php(651): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#40 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#41 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#42 /Users/arturas/***/ure/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#43 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#44 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#45 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#46 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#47 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#48 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#49 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#50 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#51 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#52 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#53 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#54 /Users/arturas/***/ure/vendor/fruitcake/laravel-cors/src/HandleCors.php(38): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#55 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#56 /Users/arturas/***/ure/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#57 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#58 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#59 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#60 /Users/arturas/***/ure/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#61 /Users/arturas/***/ure/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#62 /Users/arturas/.composer/vendor/laravel/valet/server.php(234): require('/Users/arturas/...')
#63 {main}
"} 

@freekmurze
Copy link
Member

I wonder if it has something to do with composer. If you report further errors, do mention the composer version number as well.

@voicecode-bv
Copy link

I wonder if it has something to do with composer. If you report further errors, do mention the composer version number as well.

Composer 2.0.13 on my side

@dejagersh
Copy link

dejagersh commented Jan 19, 2022

2.1.3 here locally
2.2.4 on production

@domthomas-dev
Copy link
Author

2.2.4 for me.
The problem is when I use Log Facade.

@3rgo
Copy link

3rgo commented Jan 23, 2022

Happening to me too...
After some trials, I found out that it happens when I have any error, in my case in a controller if that helps (though I think it won't...). Any error triggering an exception will do (syntax error, missing translation, ...).
The weird thing is that in the action code, I do not call ray at all.

Versions :

  • Ubuntu 20.04
  • PHP 8.1.1
  • Composer 2.2.4
  • Laravel 8.78.1
  • Laravel Sail 1.12.12
  • spatie/ray 1.33.1
  • spatie/laravel-ray 1.29.0
  • Docker 20.10.12
  • Docker-Compose 1.25.4
  • Ray 1.19.0 (with published docker config file)

Hope it helps fixing it

@StanBarrows
Copy link

We're running into the same issue when using the array_merge function within our Controller without providing array parameter.

  • Laravel Valet
  • PHP 8.1.1 (cli)
  • Composer 2.2.4 2022-01-08

@ggelashvili
Copy link

ggelashvili commented Jan 27, 2022

Having the same issue. We don't use ray but it is used by one of the dependencies seems like.

  • Composer 2.2.4
  • PHP 8.1.1
  • The dependency that uses laravel-ray: orchestra/testbench which is used by psalm/plugin-laravel <-- is our dependency

The issue started after upgrading Composer to v2 & PHP to 8.1.

Update
Looks like for our case the issue is related to the PHP upgrade from 8.0 to 8.1. At first, I thought it was composer but with PHP 8.0 & composer 2 the issue can't be reproduced. I'm going to do a further investigation but my guess is that there is some PHP 8.1 error being triggered before the ApplicationLogPayload is loaded. Thought this might help others having this issue to debug as well.

@szhorvath
Copy link

We are having the same issue after upgrading to PHP 8.1

@freekmurze
Copy link
Member

I believe that it is a problem, but I still can't reproduce it. I'd be grateful if anyone here can make a small Laravel app that demonstrates the problem.

@szhorvath
Copy link

szhorvath commented Jan 28, 2022

I believe that it is a problem, but I still can't reproduce it. I'd be grateful if anyone here can make a small Laravel app that demonstrates the problem.

@freekmurze I have been trying to recreate it locally without success. In my case, the error only occurs on our staging server. For local env, I use Laravel Sail but with the same PHP 8.1.1 version, composer 2.2 and so on. So I think it is not necessarily the PHP version that breaks it.

Laravel version 8.81.0
Laravel locale en
Laravel config cached false
PHP version 8.1.1
Composer version 2.2.5
Laravel Telescope: 4.7.0
Laravel Sentry: 2.11

cdn-loop: cloudflare
scheme: https
port: 8443

At the end of debug stack I have debug level log message:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails 

And a warning level message:

Return type of Opis\Closure\ReflectionClosure::isStatic() should either be compatible with ReflectionFunctionAbstract::isStatic(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/releases/.../vendor/opis/closure/src/ReflectionClosure.php on line 49

image

Not sure if any of this is helpful.

@affektde
Copy link
Collaborator

We had the same issue.
In our case the php8.1-redis extension was missing.

We've upgraded to PHP8.1 and our Laravel Sail docker runtime was outdated.

@sarperkaya
Copy link

I had same issue.

In my case I created PHP8.1 Enums in 'App/Enums' directory.

When I call
MyEnum::from(notContainingValueFromEnum)

the issue occurs

didn't test with fresh laravel installation

@keizah7
Copy link

keizah7 commented Feb 1, 2022

It throws that error in all exceptions

@KennedyTedesco
Copy link

Same issue here. For instance, I don't have JIT enabled. I'm using PHP 8.1.

Error Class "Spatie\Ray\Payloads\ApplicationLogPayload" not found 
    vendor/spatie/laravel-ray/src/Watchers/ApplicationLogWatcher.php:24 Spatie\LaravelRay\Watchers\ApplicationLogWatcher::Spatie\LaravelRay\Watchers\{closure}
    vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:421 Illuminate\Events\Dispatcher::Illuminate\Events\{closure}
    vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:249 Illuminate\Events\Dispatcher::dispatch
    vendor/laravel/framework/src/Illuminate/Log/Logger.php:245 Illuminate\Log\Logger::fireLogEvent
    vendor/laravel/framework/src/Illuminate/Log/Logger.php:186 Illuminate\Log\Logger::writeLog
    vendor/laravel/framework/src/Illuminate/Log/Logger.php:106 Illuminate\Log\Logger::warning
    vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:102 Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}
    vendor/laravel/framework/src/Illuminate/Support/helpers.php:418 with
    vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:105 Illuminate\Foundation\Bootstrap\HandleExceptions::handleDeprecation
    vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:72 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
    vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:228 Illuminate\Foundation\Bootstrap\HandleExceptions::Illuminate\Foundation\Bootstrap\{closure}
    vendor/composer/ClassLoader.php:571 include
    vendor/composer/ClassLoader.php:571 Composer\Autoload\includeFile
    vendor/composer/ClassLoader.php:428 Composer\Autoload\ClassLoader::loadClass
    vendor/spatie/laravel-ray/src/Watchers/ApplicationLogWatcher.php:24 Spatie\LaravelRay\Watchers\ApplicationLogWatcher::Spatie\LaravelRay\Watchers\{closure}
    vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:421 Illuminate\Events\Dispatcher::Illuminate\Events\{closure}
    vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:249 Illuminate\Events\Dispatcher::dispatch
    vendor/laravel/framework/src/Illuminate/Log/Logger.php:245 Illuminate\Log\Logger::fireLogEvent
    vendor/laravel/framework/src/Illuminate/Log/Logger.php:186 Illuminate\Log\Logger::writeLog
    vendor/laravel/framework/src/Illuminate/Log/Logger.php:94 Illuminate\Log\Logger::error
    vendor/laravel/framework/src/Illuminate/Log/LogManager.php:590 Illuminate\Log\LogManager::error
    vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:249 Illuminate\Foundation\Exceptions\Handler::report
    vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:49 Illuminate\Routing\Pipeline::handleException
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}

@szhorvath
Copy link

Any progress on this? I had to remove ray from all platforms as I could not find a solution. But I love using ray. 😢

@ThomasEnssner
Copy link
Contributor

ThomasEnssner commented Feb 22, 2022

This PR is a workaround. It isn't a real solution, but it solves the issue. And many of us are struggling with this for over six weeks.

@freekmurze
Copy link
Member

I agree that this has been going on too long. Thanks for the temporary fix. I do hope we'll find the real problem and proper solution in the future.

@judgej
Copy link

judgej commented Mar 1, 2022

Using Laravel 8.83, started for us moving from PHP 8.0 to 8.1.1

Fixed by updating the ray.php config file, that was published some versions earlier, so lacked some entries.

How the old config can create what looks like a composer autoloader problem, I can't explain, but hopefully useful evidence to add to the pile.

@dejagersh
Copy link

It's not only ApplicationLogPayload, got a similar error now on ColorPayload

image

@freekmurze
Copy link
Member

@thejager Do you perhaps have an idea on how to reproduce this?

@kg-bot
Copy link

kg-bot commented Mar 8, 2022

I had the same issue, solved with updating spatie/ray to version 1.34 composer update spatie/laravel-ray --with-dependencies

@Nielsvanpach
Copy link
Member

which composer version are you using?

@kg-bot
Copy link

kg-bot commented Mar 8, 2022

@Nielsvanpach

which composer version are you using?

Composer version 2.0.11 2021-02-24 14:57:23

EDIT: I forgot to mention this also happened in production where we use different composer version
Composer version 2.2.7 2022-02-25 11:12:27

@voicecode-bv
Copy link

Got another one, Class "Spatie\LaravelRay\OriginFactory" not found.

Sorry to say so, but as much as I love this tool, it's getting useless.

@freekmurze
Copy link
Member

freekmurze commented Mar 8, 2022

@voicecode-bv Please try to keep comments constructive.

I'm using Ray myself extensively, and I've come across this problem only once. I believe that there is indeed a problem somewhere. The hard part is getting it reproducible. Still welcoming any tips and help for this.

@kg-bot
Copy link

kg-bot commented Mar 8, 2022

Back to this, updating spatie/ray didn't solve the issue, it does happen less often but it still happens.

I noticed that issue Error: Class "Spatie\Ray\Payloads\ColorPayload" not found only happens when I try to use Log:: facade so it might help you during the debugging.

@marickvantuil
Copy link

Also getting this in a personal project. In our situation, the issue was solved by disabling OPCache. The data is a bit preliminary - I have yet to see if the issue actually stays away. Imo it would really explain some of the issues other users have reported: it happening occasionally or disappearing after renaming the file.

When the issue occurred I tried to manually let OPCache compile the file by using this line of code:

opcache_compile_file(__DIR__.'/../vendor/spatie/ray/src/Payloads/ColorPayload.php');

And that throws the following error:

Screenshot 2022-03-08 at 19 10 17

Yet with another random file it does not throw that same error:

opcache_compile_file(__DIR__.'/../vendor/laravel/framework/src/Illuminate/Database/ClassMorphViolationException.php');

Wondering if other people can confirm or disprove this?

Anyway, I cannot reproduce this in a new Laravel app, but can do it in the personal project and don't mind having a small debug session though video call if that helps find the issue.

@voicecode-bv
Copy link

@voicecode-bv Please try to keep comments constructive.

I'm using Ray myself extensively, and I've come across this problem only once. I believe that there is indeed a problem somewhere. The hard part is getting it reproducible. Still welcoming any tips and help for this.

Sorry if my response was a bit harsh, I was not my intention, probably the Dutch direct mentality ;-) I was just a bit frustrated because I had to remove this tool from 8 projects already in the last couple of months, because it was causing all kinds of trouble. I think sometimes we should all be a bit critical, only with good intentions. Especially when it comes to a a paid tool. (Yes I know it's still good value for money).

To be more constructive, the Class "Spatie\LaravelRay\OriginFactory" not found was thrown after an Exact api call throwing a 400 error.

@fullstackfool
Copy link
Contributor

fullstackfool commented Mar 9, 2022

Hi @freekmurze posting my situation, hopefully may help narrow this down:

[2022-03-09 09:41:56] local.ERROR: Class "Illuminate\Support\Optional" not found {"exception":"[object] (Error(code: 0): Class \"Illuminate\\Support\\Optional\" not found at vendor/laravel/framework/src/Illuminate/Support/helpers.php:187)
[stacktrace]
#0 vendor/spatie/laravel-ray/src/OriginFactory.php(31): optional(Object(Spatie\\Backtrace\\Frame))
#1 vendor/spatie/ray/src/Payloads/Payload.php(56): Spatie\\LaravelRay\\OriginFactory->getOrigin()
#2 vendor/spatie/ray/src/Payloads/Payload.php(42): Spatie\\Ray\\Payloads\\Payload->getOrigin()
#3 vendor/spatie/ray/src/Request.php(30): Spatie\\Ray\\Payloads\\Payload->toArray()
#4 [internal function]: Spatie\\Ray\\Request->Spatie\\Ray\\{closure}(Object(Spatie\\Ray\\Payloads\\ApplicationLogPayload))
#5 vendor/spatie/ray/src/Request.php(31): array_map(Object(Closure), Array)
#6 vendor/spatie/ray/src/Request.php(42): Spatie\\Ray\\Request->toArray()
#7 vendor/spatie/ray/src/Client.php(77): Spatie\\Ray\\Request->toJson()
#8 vendor/spatie/ray/src/Ray.php(760): Spatie\\Ray\\Client->send(Object(Spatie\\Ray\\Request))
#9 vendor/spatie/laravel-ray/src/Ray.php(507): Spatie\\Ray\\Ray->sendRequest(Array, Array)
#10 vendor/spatie/laravel-ray/src/Watchers/ApplicationLogWatcher.php(33): Spatie\\LaravelRay\\Ray->sendRequest(Object(Spatie\\Ray\\Payloads\\ApplicationLogPayload))
#11 vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(404): Spatie\\LaravelRay\\Watchers\\ApplicationLogWatcher->Spatie\\LaravelRay\\Watchers\\{closure}(Object(Illuminate\\Log\\Events\\MessageLogged))
#12 vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}('Illuminate\\\\Log\\\\...', Array)
#13 vendor/laravel/framework/src/Illuminate/Log/Logger.php(245): Illuminate\\Events\\Dispatcher->dispatch('Illuminate\\\\Log\\\\...')
#14 vendor/laravel/framework/src/Illuminate/Log/Logger.php(186): Illuminate\\Log\\Logger->fireLogEvent('warning', 'Return type of ...', Array)
#15 vendor/laravel/framework/src/Illuminate/Log/Logger.php(106): Illuminate\\Log\\Logger->writeLog('warning', 'Return type of ...', Array)
#16 vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(105): Illuminate\\Log\\Logger->warning('Return type of ...')
#17 vendor/laravel/framework/src/Illuminate/Support/helpers.php(377): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}(Object(Illuminate\\Log\\Logger))
#18 vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(108): with(Object(Illuminate\\Log\\Logger), Object(Closure))
#19 vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleDeprecation('Return type of ...', '/Users/fsf...', 63)
#20 vendor/composer/ClassLoader.php(571): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8192, 'Return type of ...', '/Users/fsf...', 63)
#21 vendor/composer/ClassLoader.php(571): include('/Users/fsf...')
#22 vendor/composer/ClassLoader.php(428): Composer\\Autoload\\includeFile('/Users/fsf...')
#23 vendor/laravel/framework/src/Illuminate/Support/helpers.php(187): Composer\\Autoload\\ClassLoader->loadClass('Illuminate\\\\Supp...')
#24 app/Providers/RouteServiceProvider.php(51): optional(NULL)
... etc, etc (Standard laravel routing & middleware calls)

  • Only happens if the ray client is running. If I close the client then the API call completes successfully, with no issues. Restart the Ray client and API returns above 500.
  • SEND_REQUESTS_TO_RAY = false
  • php 8.1
  • composer -vvv about: Running 2.2.6 (2022-02-04 17:00:38) with PHP 8.1.3 on Darwin / 21.3.0
  • laravel-ray 1.29.4
  • ray client 1.19.0
  • Monterey 12.2.1

EDIT:

  • Pausing within the client also does not help, the client needs to be completely closed for the request to succeed.

@roberttolton
Copy link

Am experiencing this as well, but am curious if OPCache has anything to do with it.

Have migrated a project off of Laravel Vapor (AWS Lamba) to Laravel Forge with OPCache enabled, and only now have I seen these errors. The Vapor dockerfiles I was basing my environment off have OPCache enabled too, so I don't know why this issue would now present itself running on Forge (with all the same PHP versions) but not Vapor / Lamba.

@masterix21
Copy link
Collaborator

I had the issue in my development environment and the OPCache was off.

@brain82
Copy link

brain82 commented Apr 6, 2022

I don't know if this will help anyone, but every time I've had this problem, restarting php and nginx resolves the issue. I tend to get this error when I update the laravel-ray package via composer.

@dejagersh
Copy link

Definitely a problem with OPCache. I am having the same problem with spatie/laravel-ignition:

[2022-04-17 18:38:54] development.ERROR: Class "Spatie\LaravelIgnition\Recorders\LogRecorder\LogMessage" not found {"userId":2,"exception":"[object] (Error(code: 0): Class \"Spatie\\LaravelIgnition\\Recorders\\LogRecorder\\LogMessage\" not found at /Users/johandejager/Projects/Laptify/salonbase/vendor/spatie/laravel-ignition/src/Recorders/LogRecorder/LogRecorder.php:39)

I added opcache_reset() to my index.php and it worked again.

@freekmurze
Copy link
Member

freekmurze commented Jul 29, 2022

I've not seen this exception now for quite some time. Maybe it was fixed in Composer?

Do any of you get this exception still?

@fullstackfool
Copy link
Contributor

I've not seem this exception now for quite some time. Maybe it was fixed in Composer?

Do any of you get this exception still?

Nothing for while now. Stable for me in L8 & L9 projects @freekmurze

@3rgo
Copy link

3rgo commented Jul 29, 2022

Happening to me too... After some trials, I found out that it happens when I have any error, in my case in a controller if that helps (though I think it won't...). Any error triggering an exception will do (syntax error, missing translation, ...). The weird thing is that in the action code, I do not call ray at all.

Versions :

  • Ubuntu 20.04
  • PHP 8.1.1
  • Composer 2.2.4
  • Laravel 8.78.1
  • Laravel Sail 1.12.12
  • spatie/ray 1.33.1
  • spatie/laravel-ray 1.29.0
  • Docker 20.10.12
  • Docker-Compose 1.25.4
  • Ray 1.19.0 (with published docker config file)

Hope it helps fixing it

Yeah seems OK for me too, hasn't happened in a long while.
Versions diff :

  • PHP 8.1.1 -> 8.1.3
  • Composer 2.2.4 -> 2.3.3
  • Laravel 8.78.1 -> 8.83.20
  • Laravel Sail 1.12.12 -> 1.15.0
  • spatie/ray 1.33.1 -> 1.34.5
  • spatie/laravel-ray 1.29.0 -> 1.29.7
  • Docker 20.10.12 -> 20.10.17
  • Ray 1.19.0 -> 2.0.1

@voicecode-bv
Copy link

We're good here 👍 🙏 Thanks @freekmurze!

@roberttolton
Copy link

I've not had it show up recently either..!

@freekmurze
Copy link
Member

Going to close this for now.

If you are experiencing this error try upgrading composer to the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests