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 "Honeybadger\HoneybadgerLaravel\ContextManager" not found #91

Open
ralphjsmit opened this issue Dec 7, 2021 · 10 comments
Open

Class "Honeybadger\HoneybadgerLaravel\ContextManager" not found #91

ralphjsmit opened this issue Dec 7, 2021 · 10 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ralphjsmit
Copy link

ralphjsmit commented Dec 7, 2021

What are the steps to reproduce this issue?

  1. I installed Honeybadger in a Laravel project according to the instructions.
  2. I added Honeybadger to the register method:
    public function register()
    {
        $this->reportable(function (Throwable $e) {
            if ( app()->bound('honeybadger') ) {
                app('honeybadger')->notify($e, app('request'));
            }
        });
    }

What happens?

When there is an error, I get this error first:

Schermafbeelding 2021-12-07 om 15 52 48

What were you expecting to happen?

The regular error message should be displayed and Honeybadger should be informed.

Any logs, error output, etc?

I can send you any information you like!

It is perhaps worth mentioning that I have my Exception Handler in the Support/App/Exceptions namespace, because my Laravel project is structured according to DDD.

That means that I don't have an app folder anymore, but rather a src folder with App, Domain and Support namespaces. Could it be that the location of the Laravel exceptionhandler is hardcoded in Honeybadger?

On the other hand, the Exception handler is just registered as a singleton in the bootstrap/app.php file and it works for the 'regular' exceptions:

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    Support\App\Exceptions\Handler::class
);

Any other comments?

I'm using PHP 8.1.

What versions are you using?

Operating System: MacOS
Package Version: ^3.12

@shalvah
Copy link
Contributor

shalvah commented Dec 7, 2021

Can you share the other stack trace frames (48-49)?

@ralphjsmit
Copy link
Author

ralphjsmit commented Dec 7, 2021

The count is a little bit different (think because I simulated a different error), but here are the screenshots (I skipped the Composer autoloader ones):

Schermafbeelding 2021-12-07 om 17 29 26

Schermafbeelding 2021-12-07 om 17 29 30

Schermafbeelding 2021-12-07 om 17 29 38

Schermafbeelding 2021-12-07 om 17 29 45

Schermafbeelding 2021-12-07 om 17 29 48

Schermafbeelding 2021-12-07 om 17 29 52

@shalvah
Copy link
Contributor

shalvah commented Dec 8, 2021

This is strange. That class definitely exists, and it should be loaded. Can you try running composer dump-autoload again?

@ralphjsmit
Copy link
Author

Hmm, I already tried running that, but that didn't help. After yesterday I didn't experience the problem anymore locally, so perhaps it was because I shut down my Mac for the night. Don't know.

About an hour ago I got an Honeybadger email that the error happened again, only on production. Don't know how it possible that I still got notified about that.

Is there an email I can reach you on, so I can send you the public Honeybadger link to the error?

@joshuap
Copy link
Member

joshuap commented Dec 14, 2021

Hmm, I already tried running that, but that didn't help. After yesterday I didn't experience the problem anymore locally, so perhaps it was because I shut down my Mac for the night. Don't know.

About an hour ago I got an Honeybadger email that the error happened again, only on production. Don't know how it possible that I still got notified about that.

Is there an email I can reach you on, so I can send you the public Honeybadger link to the error?

Hey @ralphjsmit, feel free to email here: support@honeybadger.io — thanks!

@shalvah
Copy link
Contributor

shalvah commented Jan 14, 2022

Hi @ralphjsmit, this is quite tricky. From the trace you shared, it seems the original error is thrown after the SubstituteBindings middleware on production, but before any route gets processed. Do you have an idea what that error is? It could be that another package added a middleware dynamically (Laravel Breeze does this), which causes the error. It seems for some reason the class isn't found at the time, but in handling the "class not found" error, the class is then found.🤔

Also, can you verify that the file indeed exists on your filesystem? If you can SSH into your app's folder and ls vendor/honeybadger-io/honeybadger-laravel/src, that would be great.

I don't think your exception handler being in a different namespace should affect things. That's a Laravel issue, but this is a case of Composer not finding a class.

However, I do suspect that it's something unique to your setup, maybe a Composer failure. What version of Composer are you running?

@ralphjsmit
Copy link
Author

Hey @shalvah, thank you for your thorough investigation and coming back to me. When I do the ls command, I get the following output, so I guess that this should look right:

Breadcrumbs         Contracts                 HoneybadgerServiceProvider.php
CommandTasks.php    Exceptions                Installer.php
Commands            Facades                   Middleware
Concerns            HoneybadgerLaravel.php
ContextManager.php  HoneybadgerLogDriver.php

Anyway, I've removed the vendor folders and done a fresh install. I'll keep an eye on the errors and if it doesn't occur anymore, I'll close this issue.

Thank you for the support!

@shalvah
Copy link
Contributor

shalvah commented Jan 18, 2022

Alright, sure thing.

@subzero10
Copy link
Member

I'm closing this because it's inactive. Feel free to re-open if this happens again!

@chrisdicarlo
Copy link

chrisdicarlo commented Jan 5, 2024

I still get this error randomly but when it does happen, it's seems consistent. I'm on the most recent package version. When it does happen I see 2 exceptions being thrown, the first is the one I expect, the second is:

Class "Honeybadger\HoneybadgerLaravel\ContextManager" not found

Any ideas help on how I can try to debug this issue? I suspect it's related to the middleware, as mentioned above, but I have been unable to trap exactly which one. I've just been disabling the error reporting completely when I run into it but obviously that defeats the purpose. Thanks for any help!

@subzero10 subzero10 reopened this Jan 10, 2024
@joshuap joshuap added bug Something isn't working help wanted Extra attention is needed labels Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants