honeybadger-laravel
honeybadger-laravel copied to clipboard
Class "Honeybadger\HoneybadgerLaravel\ContextManager" not found
What are the steps to reproduce this issue?
- I installed Honeybadger in a Laravel project according to the instructions.
- 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:
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
Can you share the other stack trace frames (48-49)?
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):
This is strange. That class definitely exists, and it should be loaded. Can you try running composer dump-autoload again?
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?
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: [email protected] — thanks!
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?
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!
Alright, sure thing.
I'm closing this because it's inactive. Feel free to re-open if this happens again!
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!
Closing because of inactivity.