bugsnag/bugsnag-laravel

Only errors within models are reported

deanzod opened this issue · 11 comments

I have a laravel/livewire project and I have noticed that if I encounter an error directly in a model, it send a report to bugsnag. If I try and throw an error in a controller or livewire controller I get the error in my laravel log file but nothing goes to bugsnag. Even if I try and explicitly do a Bugsnag::notifyException() from a controller it does nothing.

Environment

Bugnsag-laravel v2.22.0
Bugsnag v3.26.0
PHP 7.4
Composer v2.0.9
Laravel 8.29.0

Example of error that doesn't make it to Busgnag:

production.ERROR: Undefined index: value {"userId":1,"exception":"[object] (ErrorException(code: 0): Undefined index: value at /var/www/html/vendor/livewire/livewire/src/HydrationMiddleware/PerformDataBindingUpdates.php:18)

Hi @deanzod,

Would you be able to share your complete Bugsnag configuration code along with the code you are using to trigger this error. If you prefer not to share that here you can send it to us via support@bugsnag.com.

Thanks

@johnkiely1 The config file is untouched. In My .env file I have:


BUGSNAG_API_KEY=MyKey
BUGSNAG_NOTIFY_RELEASE_STAGES=production

To trigger errors I have tried allsorts including deliberatly adding unknown properties, undefined indexes, mis-spelled variables etc... along with this:

try {
            throw new \exception("testing 123");
        } catch (\exception $e) {
            Bugsnag::notifyException($e); 
        }

All of the attempts work when done within a model but when the error is in a controller (normal or livewire) it just ends up in the laravel log file and doesn't get picked up by bugsnag at all

@deanzod,

Are you also setting your release stage somewhere? If not I would suggest you do and set it to production, if only for testing purposes. Alternatively you could remove BUGSNAG_NOTIFY_RELEASE_STAGES=production so everything should be allowed to be sent.

You could try varying the batchSending value to see if it makes any difference.

It may also be worth you emailing to support@bugsnag.com with some links to the errors that have made it through to the Bugsnag dashboard (ie those from models) as there may be some useful information for us to check on those.

Additionally if you could show us your logging set up similar to what is described here, that would also be helpful.

@deanzod
If you're still seeing this issue can you share full details of how you've configured logging and how to reproduce and we'll re-open this and investigate further.

@johnkiely1 sorry for the very late reply...

This is exactly how I have it set up on other older projects which works so the only difference I can think of between this and others is that this one uses Stancl/tenancy pacakge

My logging:

  'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily', 'bugsnag'],
            'ignore_exceptions' => false,
        ],
        'bugsnag' => [
            'driver' => 'bugsnag',
        ], ....

My bugsnag config file is untouched/as default install

My config/app.php file:

....
   Illuminate\Validation\ValidationServiceProvider::class,
        Illuminate\View\ViewServiceProvider::class,

        /*
         * Package Service Providers...
         */
        //  Barryvdh\Debugbar\ServiceProvider::class,
        Barryvdh\DomPDF\ServiceProvider::class,
        Bugsnag\BugsnagLaravel\BugsnagServiceProvider::class,


        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
...


        'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
        'Bugsnag' => Bugsnag\BugsnagLaravel\Facades\Bugsnag::class,
        'Bus' => Illuminate\Support\Facades\Bus::class,

....

Hi @deanzod, yes that all looks ok, and we don't expect Stancl/tenancy package to be at fault here. I've tried some basic reproduction examples but been unable to reproduce what you are seeing. It is clearly something much more subtle at fault here.

Would you be able to share a cut down reproduction example project that exhibits this behaviour which should allow us to investigate this further.

Would you be able to share a cut down reproduction example project that exhibits this behaviour which should allow us to investigate this further.

ok, it might take me a little while to get this sorted but I will try and get a failing minimal setup into a repo asap. Thanks

@johnkiely1 sorry it took me a while to get back to this but when I set up a new project to get it ready to share I think I've made some progress on getting closer to a cause.

I created a fresh laravel project
installed bugsnag with minimal config
created a route pointing to a controller and added the test line Bugsnag::notifyException(new RuntimeException("Test from controller")); in the controller method
php artisan serve and visited the route

Bug was reported as expected in bugsnag.

Stopped artisan serve, Installed homestead and ran vagrant up
Visited the route and bug fails to report to bugsnag

So it seems this is a server related issue somehow. So bugsnag works fine on artisan serve but doesn't work on homestead or production LAMP server.

Any idea what could be causing that?

Hi @deanzod,

Perhaps there is some restriction from your server when making the outbound request.

Would you be able to check if your server can access notify.bugsnag.com by running something along the lines of curl notify.bugsnag.com/ping from within your server environment. If accessible you should see

pong as the response.

Let me know how you get on with this.

@johnkiely1 I just tried this within homestead and did get pong but it took about 5 or 6 seconds. Also tested it on the server and it worked ok and returned instantly.

Just checking on the server laravel log file and I can see there have been a few undefined variable errors recorded but they never came through to bugsnag. Is there anything else I can try?

Hi @deanzod

I just tried this within homestead and did get pong but it took about 5 or 6 seconds

That seems odd. I'd recommend investigating why this takes so long.

I suspect the missing error reports are caused by the same issue and the requests may be timing out. You should be able to check the logs on the server. Bugsnag should log an error starting Bugsnag Warning: Couldn't notify with further details on the reason if it fails to send the report:
https://github.com/bugsnag/bugsnag-php/blob/36d7a22d60e72b6c750ad1600dc5ae5d4073598d/src/HttpClient.php#L332