-
-
Notifications
You must be signed in to change notification settings - Fork 613
Breaking change after upgrading from 2.0.3 to 2.0.4. Error: Call to undefined method class@anonymous::onRequestHandled() #530
Comments
You haven't changed anything else? Not sure why the HandleCors class would be null if it's resolved from the container |
No other changes. Reverted back to the previous version 2.0.3 and everything works properly with the above config. |
With Laravel 8? No Octane or anything? I just did Does it happen immediately? Or on CORS requests? |
It's strange cause this is calling it: $this->app->make(HandleCors::class)->onRequestHandled($event); But why would that be null. It registered in |
This is Laravel 8 standard without Octane. The error happened during testing. |
What do you mean during testing? A unit test? How does it look? |
Yes during a unit (feature) controller test. Standard Laravel test setup. The test bootstrap loads the HTTP kernel normally, so I would assume this would also happen outside the tests. |
I got the same error after upgrading to 2.0.4. from 2.0.3 on Laravel 8.44.0, no Octane. /**
* @test
* @return void
*/
public function verifyResponse(): void
{
$this->withoutMiddleware([HandleCors::class])
$response = $this->call('GET', '/api/v1/some-route');
$response->assertStatus(Response::HTTP_OK);
} Here is the call stack:
After reverting to 2.0.3 the issue is resolved. |
I am getting this error after upgrading the package.
This is caused by HandleCors::class not resolving from the container. Seems like the package now has an issue if HandleCors::class is loaded in $middlewareGroups. Adding HandleCors::class to the $middleware array does not solve the issue either. We have 3 different middleware groups and we are only using HandleCors::class in one of them.
Error: Call to undefined method class@anonymous::onRequestHandled() /var/www/html/vendor/fruitcake/laravel-cors/src/CorsServiceProvider.php:42 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:392 /var/www/html/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:237 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:118
Here is the HTTP kernel
The text was updated successfully, but these errors were encountered: