getsentry / sentry-laravel

The official Laravel SDK for Sentry (sentry.io)
https://sentry.io
MIT License
1.23k stars 189 forks source link

Lumen without facades #919

Closed btamas86 closed 1 month ago

btamas86 commented 1 month ago

How do you use Sentry?

Self-hosted / on-premises

SDK version

4.6.1

Laravel version

11.15.0

Steps to reproduce

I use the Laravel Lumen 11 version. The problem only occurs when I don't use $app->withFacades();. I think the problem is in Sentry\Laravel\Integration\LaravelContextIntegration when Context::all() is called, because facades are not initialized.

Expected result

It should send performance data.

Actual result

Fatal error: Uncaught RuntimeException: A facade root has not been set. in /var/www/html/vendor/illuminate/support/Facades/Facade.php:354 Stack trace: #0 /var/www/html/vendor/sentry/sentry-laravel/src/Sentry/Laravel/Integration/LaravelContextIntegration.php(33): Illuminate\Support\Facades\Facade::__callStatic('all', Array) #1 /var/www/html/vendor/sentry/sentry/src/State/Scope.php(415): Sentry\Laravel\Integration\LaravelContextIntegration::Sentry\Laravel\Integration{closure}(Object(Sentry\Event), Object(Sentry\EventHint)) #2 /var/www/html/vendor/sentry/sentry/src/Client.php(322): Sentry\State\Scope->applyToEvent(Object(Sentry\Event), Object(Sentry\EventHint), Object(Sentry\Options)) #3 /var/www/html/vendor/sentry/sentry/src/Client.php(175): Sentry\Client->prepareEvent(Object(Sentry\Event), Object(Sentry\EventHint), Object(Sentry\State\Scope)) #4 /var/www/html/vendor/sentry/sentry/src/Client.php(167): Sentry\Client->captureEvent(Object(Sentry\Event), Object(Sentry\EventHint), Object(Sentry\State\Scope)) #5 /var/www/html/vendor/sentry/sentry/src/State/Hub.php(142): Sentry\Client->captureException(Object(Symfony\Component\ErrorHandler\Error\FatalError), Object(Sentry\State\Scope), Object(Sentry\EventHint)) #6 /var/www/html/app/Exceptions/Handler.php(58): Sentry\State\Hub->captureException(Object(Symfony\Component\ErrorHandler\Error\FatalError)) #7 /var/www/html/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php(200): App\Exceptions\Handler->report(Object(Symfony\Component\ErrorHandler\Error\FatalError)) #8 /var/www/html/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php(137): Laravel\Lumen\Application->handleException(Object(Symfony\Component\ErrorHandler\Error\FatalError)) #9 /var/www/html/vendor/laravel/lumen-framework/src/Concerns/RegistersExceptionHandlers.php(55): Laravel\Lumen\Application->handleShutdown() #10 [internal function]: Laravel\Lumen\Application->Laravel\Lumen\Concerns{closure}() #11 {main} thrown in /var/www/html/vendor/illuminate/support/Facades/Facade.php on line 354

cleptric commented 1 month ago

A fix for this issue was released in 4.7.1.

btamas86 commented 1 month ago

Thank you very much!