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

StreamHandler class not found when logging deprecation warnings #41035

Closed
smknstd opened this issue Feb 15, 2022 · 26 comments
Closed

StreamHandler class not found when logging deprecation warnings #41035

smknstd opened this issue Feb 15, 2022 · 26 comments
Assignees

Comments

@smknstd
Copy link

smknstd commented Feb 15, 2022

  • Laravel Version: 8.80
  • PHP Version: 8.1
  • Database Driver & Version: mysql 8

Description:

When trying to use deprecation logging feature, some of my endpoint crashes with error 500 and nothing is catched in laravel's logs. I found this in /var/log/nginx/myproject-error.log :

[error] 815505#815505: *1186160 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Class "Monolog\Handler\StreamHandler" not found in /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:175
Stack trace:
#0 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger()
#1 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get()
#2 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager->driver()
#3 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(101): Illuminate\Log\LogManager->channel()
#4 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(72): Illuminate\Foundation\Bootstrap\HandleExceptions->handleDeprecation()
#5 /home/forge/myproject/vendor...PHP message: PHP Fatal error:  Uncaught Error: Class "Monolog\Handler\StreamHandler" not found in /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:175
Stack trace:
#0 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger()
#1 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get()
#2 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager->driver()
#3 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(101): Illuminate\Log\LogManager->channel()
#4 /home/forge/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(72): Illuminate\Foundation\Bootstrap\HandleExceptions->han

It looks pretty similar to #39938

Steps To Reproduce:

in config/logging.php :


'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),

'channels' => [
        ...
        'php_deprecation_warnings' => [
            'driver' => 'single',
            'path' => storage_path('logs/php-deprecation-warnings.log'),
        ],
]

in .env :

LOG_DEPRECATIONS_CHANNEL=php_deprecation_warnings
@smknstd smknstd changed the title Log handler class not found when logging deprecation warnings StreamHandler class not found when logging deprecation warnings Feb 15, 2022
@nunomaduro
Copy link
Member

@smknstd I will need you to send me the full error output.

@smknstd
Copy link
Author

smknstd commented Feb 15, 2022

Hello @nunomaduro ! This is all I got unfortunately it seems truncated or something in nginx logs for some reason ...

@nunomaduro
Copy link
Member

Are you running the latest version of monolog? Do you mind upgrading that package?

@smknstd
Copy link
Author

smknstd commented Feb 15, 2022

I think it is the last version. From composer lock:

        {
            "name": "monolog/monolog",
            "version": "2.3.5",

@hmazter
Copy link
Contributor

hmazter commented Feb 16, 2022

I encountered the same error in our staging environment this morning after upgrading to framework version v8.83.1.
Could not get it to trigger locally though.

Rolling back to v8.83.0 did not solve it though.

monolog versions: 2.3.5

We use LOG_DEPRECATIONS_CHANNEL=stderr

Stacktrace
Error: Class "Monolog\Handler\StreamHandler" not found
#24 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): Illuminate\Log\LogManager::createEmergencyLogger
#23 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get
#22 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver
#21 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager::channel
#20 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(101): Illuminate\Foundation\Bootstrap\HandleExceptions::handleDeprecation
#19 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(72): Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
#18 /vendor/composer/ClassLoader.php(571): include
#17 /vendor/composer/ClassLoader.php(571): Composer\Autoload\includeFile
#16 /vendor/composer/ClassLoader.php(428): Composer\Autoload\ClassLoader::loadClass
#15 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): Illuminate\Log\LogManager::createEmergencyLogger
#14 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get
#13 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver
#12 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager::error
#11 /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(261): Illuminate\Support\Facades\Facade::__callStatic
#10 /app/Exceptions/Sentry.php(24): App\Exceptions\Sentry::captureException
#9 /app/Exceptions/Handler.php(36): App\Exceptions\Handler::App\Exceptions\{closure}
#8 [internal](0): call_user_func
#7 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/ReportableHandler.php(45): Illuminate\Foundation\Exceptions\ReportableHandler::__invoke
#6 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(235): Illuminate\Foundation\Exceptions\Handler::report
#5 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(49): Illuminate\Routing\Pipeline::handleException
#4 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(172): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#3 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline::then
#2 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Foundation\Http\Kernel::sendRequestThroughRouter
#1 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel::handle
#0 /public/index.php(52): null

@hmazter
Copy link
Contributor

hmazter commented Feb 16, 2022

@smknstd Do you have Sentry or some other exception handling service?
Trying to guess if that has any effect

@smknstd
Copy link
Author

smknstd commented Feb 16, 2022

Great point ! Yes, we have getsentry/sentry-laravel 2.11.0

@nunomaduro
Copy link
Member

Can you share the full "logging.php" file?

@hmazter
Copy link
Contributor

hmazter commented Feb 17, 2022

This is our config/logging.php

<?php

use Monolog\Handler\StreamHandler;

return [
    'default' => env('LOG_CHANNEL', 'stderr'),

    'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'stderr'),

    'channels' => [
        // Should  be used for docker
        'stderr' => [
            'driver' => 'monolog',
            'handler' => StreamHandler::class,
            'formatter' => env('LOG_STDERR_FORMATTER'),
            'tap' => [
                \App\Logging\AddAmznTraceIdContext::class,
                \App\Logging\AddRecruiterIdContext::class,
            ],
            'level' => env('LOG_LEVEL', 'debug'),
            'with' => [
                'stream' => 'php://stderr',
            ],
        ],
    ],
];

@nunomaduro
Copy link
Member

@hmazter Can't reproduce your issue. But aren't you missing an emergency channel there?

https://github.com/laravel/laravel/blob/4a6229aa654faae58f8ea627f4b771351692508c/config/logging.php#L114

@driesvints
Copy link
Member

I'd also recommend against modifying the logging.php file like that. It's best that you leave the defaults in place.

@hmazter
Copy link
Contributor

hmazter commented Feb 17, 2022

There was no emergency when we created the app back in Laravel 6.
And it has worked, probably since the emergency logger has a fallback in the code

$config = $this->configurationFor('emergency');
$handler = new StreamHandler(
$config['path'] ?? $this->app->storagePath().'/logs/laravel.log',
$this->level(['level' => 'debug'])
);

@driesvints
Copy link
Member

@hmazter you should always update config files when upgrading Laravel versions. Tools like Laravel Shift can greatly help with this.

@nunomaduro
Copy link
Member

@hmazter Can you create the emergency channel and let me know how it goes @hmazter ?

@hmazter
Copy link
Contributor

hmazter commented Feb 17, 2022

And unfortunately, I can't reproduce it locally either, so I have no way to inspect what the initial exception is.

you should always update config files when upgrading Laravel versions. Tools like Laravel Shift can greatly help with this.

Totally agree with you.
Only that the config for the emergency logger, in this case, is what is the default in the code any way.

But I'll add the emergency logger and test.

@smknstd
Copy link
Author

smknstd commented Feb 17, 2022

here is the whole config/logging.php:

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Log Channel
    |--------------------------------------------------------------------------
    |
    | This option defines the default log channel that gets used when writing
    | messages to the logs. The name specified in this option should match
    | one of the channels defined in the "channels" configuration array.
    |
    */

    'default' => env('LOG_CHANNEL', 'stack'),

    /*
    |--------------------------------------------------------------------------
    | Log Channels
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log channels for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Drivers: "single", "daily", "slack", "syslog",
    |                    "errorlog", "custom", "stack"
    |
    */

    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily', 'sentry'],
            'name' => 'laravel'
        ],

        'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => storage_path('logs/laravel.log'),
            'level' => 'debug',
            'days' => 7,
        ],

        'slack' => [
            'driver' => 'slack',
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
            'level' => 'critical',
        ],

        'syslog' => [
            'driver' => 'syslog',
            'level' => 'debug',
        ],

        'errorlog' => [
            'driver' => 'errorlog',
            'level' => 'debug',
        ],

        'sentry' => [
            'driver' => 'sentry',
            'level'  => env('SENTRY_LOG_LEVEL', 'error')
        ],

        'php_deprecation_warnings' => [
            'driver' => 'single',
            'path' => storage_path('logs/php-deprecation-warnings.log'),
        ],
    ],

    'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),

];

@hmazter
Copy link
Contributor

hmazter commented Feb 17, 2022

Did a deploy with this config (changed the path for emergency logger since I'm running in docker/AWS ECS and storage_path is not writable)

<?php

use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler;

return [
    /*
    |--------------------------------------------------------------------------
    | Default Log Channel
    |--------------------------------------------------------------------------
    |
    | This option defines the default log channel that gets used when writing
    | messages to the logs. The name specified in this option should match
    | one of the channels defined in the "channels" configuration array.
    |
    */

    'default' => env('LOG_CHANNEL', 'stack'),

    /*
    |--------------------------------------------------------------------------
    | Deprecations Log Channel
    |--------------------------------------------------------------------------
    |
    | This option controls the log channel that should be used to log warnings
    | regarding deprecated PHP and library features. This allows you to get
    | your application ready for upcoming major versions of dependencies.
    |
    */

    'deprecations' => env('LOG_DEPRECATIONS_CHANNEL', 'stderr'),

    /*
    |--------------------------------------------------------------------------
    | Log Channels
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log channels for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Drivers: "single", "daily", "slack", "syslog",
    |                    "errorlog", "monolog",
    |                    "custom", "stack"
    |
    */

    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['single'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path' => storage_path('logs/laravel.log'),
            'level' => env('LOG_LEVEL', 'debug'),
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => storage_path('logs/laravel.log'),
            'level' => env('LOG_LEVEL', 'debug'),
            'days' => 14,
        ],

        'slack' => [
            'driver' => 'slack',
            'url' => env('LOG_SLACK_WEBHOOK_URL'),
            'username' => 'Laravel Log',
            'emoji' => ':boom:',
            'level' => env('LOG_LEVEL', 'critical'),
        ],

        'papertrail' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => SyslogUdpHandler::class,
            'handler_with' => [
                'host' => env('PAPERTRAIL_URL'),
                'port' => env('PAPERTRAIL_PORT'),
            ],
        ],

        // Should  be used for docker
        'stderr' => [
            'driver' => 'monolog',
            'level' => env('LOG_LEVEL', 'debug'),
            'handler' => StreamHandler::class,
            'formatter' => env('LOG_STDERR_FORMATTER'),
            'tap' => [
                \App\Logging\AddAmznTraceIdContext::class,
                \App\Logging\AddRecruiterIdContext::class,
            ],
            'with' => [
                'stream' => 'php://stderr',
            ],
        ],

        'syslog' => [
            'driver' => 'syslog',
            'level' => env('LOG_LEVEL', 'debug'),
        ],

        'errorlog' => [
            'driver' => 'errorlog',
            'level' => env('LOG_LEVEL', 'debug'),
        ],

        'null' => [
            'driver' => 'monolog',
            'handler' => NullHandler::class,
        ],

        'emergency' => [
            'path' => sys_get_temp_dir() . '/emergency.log',
        ],
    ],
];

And I'm getting this stacktrace

Error: Class "Monolog\Handler\StreamHandler" not found
#62 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): Illuminate\Log\LogManager::createEmergencyLogger
#61 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get
#60 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver
#59 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager::channel
#58 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(101): Illuminate\Foundation\Bootstrap\HandleExceptions::handleDeprecation
#57 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(72): Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
#56 /vendor/composer/ClassLoader.php(571): include
#55 /vendor/composer/ClassLoader.php(571): Composer\Autoload\includeFile
#54 /vendor/composer/ClassLoader.php(428): Composer\Autoload\ClassLoader::loadClass
#53 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): Illuminate\Log\LogManager::createEmergencyLogger
#52 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get
#51 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver
#50 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager::error
#49 /vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(261): Illuminate\Support\Facades\Facade::__callStatic
#48 /app/Exceptions/Sentry.php(24): App\Exceptions\Sentry::captureException
#47 /app/Exceptions/Handler.php(36): App\Exceptions\Handler::App\Exceptions\{closure}
#46 [internal](0): call_user_func
#45 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/ReportableHandler.php(45): Illuminate\Foundation\Exceptions\ReportableHandler::__invoke
#44 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(235): Illuminate\Foundation\Exceptions\Handler::report
#43 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(49): Illuminate\Routing\Pipeline::handleException
#42 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(172): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#41 /vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\Session\Middleware\StartSession::handleStatefulRequest
#40 /vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Session\Middleware\StartSession::handle
#39 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#38 /vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::handle
#37 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#36 /vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\Cookie\Middleware\EncryptCookies::handle
#35 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#34 /app/Http/Middleware/AsyncFormRedirect.php(19): App\Http\Middleware\AsyncFormRedirect::handle
#33 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#32 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline::then
#31 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(723): Illuminate\Routing\Router::runRouteWithinStack
#30 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(698): Illuminate\Routing\Router::runRoute
#29 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\Routing\Router::dispatchToRoute
#28 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(651): Illuminate\Routing\Router::dispatch
#27 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\Foundation\Http\Kernel::Illuminate\Foundation\Http\{closure}
#26 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#25 /vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestIpMiddleware.php(45): Sentry\Laravel\Http\SetRequestIpMiddleware::handle
#24 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#23 /vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestMiddleware.php(42): Sentry\Laravel\Http\SetRequestMiddleware::handle
#22 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#21 /app/Http/Middleware/UserResponseHeaderMiddleware.php(16): App\Http\Middleware\UserResponseHeaderMiddleware::handle
#20 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#19 /app/Http/Middleware/InstrumentationMiddleware.php(21): App\Http\Middleware\InstrumentationMiddleware::handle
#18 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#17 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Foundation\Http\Middleware\TransformsRequest::handle
#16 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::handle
#15 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#14 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Foundation\Http\Middleware\TransformsRequest::handle
#13 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TrimStrings::handle
#12 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#11 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Foundation\Http\Middleware\ValidatePostSize::handle
#10 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#9 /vendor/fruitcake/laravel-cors/src/HandleCors.php(38): Fruitcake\Cors\HandleCors::handle
#8 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#7 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance::handle
#6 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#5 /vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\Http\Middleware\TrustProxies::handle
#4 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#3 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline::then
#2 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Foundation\Http\Kernel::sendRequestThroughRouter
#1 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel::handle
#0 /public/index.php(52): null

And the exception line is this:

$handler = new StreamHandler(

I'm sorry I don't have more info to work with.

@hmazter
Copy link
Contributor

hmazter commented Feb 17, 2022

Wild speculation, bit seems that the first call to createEmergencyLogger tries to autoload StreamHandler (#54-#56 in the stacktrace) and that causes the new exception with StreamHandler not found.

So, something breaks during autoload?

@hmazter
Copy link
Contributor

hmazter commented Feb 17, 2022

Just a note, I get the same behavior even if I'm removing the calls to Sentry.
And I did not think that was the problem since the exceptions got reported as expected to Sentry.

This is the shorter stack trace that is dumped by the server

NOTICE: PHP message: PHP Fatal error: Uncaught Error: Class "Monolog\Handler\StreamHandler" not found in /application/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:175
#0 /application/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger()
#1 /application/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get()
#2 /application/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager->driver()
#3 /application/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(101): Illuminate\Log\LogManager->channel()
#4 /application/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(72): Illuminate\Foundation\Bootstrap\HandleExceptions->handleDeprecation()
#5 /application/vendor/composer/ClassLoader.php(571): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#6 /application/vendor/composer/ClassLoader.php(571): include('...')
#7 /application/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
#8 /application/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): Composer\Autoload\ClassLoader->loadClass()
#9 /application/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger()
#10 /application/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get()
#11 /application/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager->driver()
#12 /application/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\Log\LogManager->error()
#13 /application/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(162): Illuminate\Foundation\Exceptions\Handler->report()
#14 /application/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(204): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException()
#15 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
#16 {main}
thrown in /application/vendor/laravel/framework/src/Illuminate/Log/LogManager.php on line 175

@nunomaduro
Copy link
Member

I don't have a way to reproduce this. I propose that we wait a little bit more, until we have other people with the same issue (if any..) and maybe they are able to provide us a way to reproduce this.

Meanwhile, if you are able to understand what's happening, let me know.

@Levivb
Copy link

Levivb commented Apr 7, 2022

Not sure whether to report here in this closed report. But since @nunomaduro waited for other people to respond - and the label on this issue is "needs more info" - I'll add my finding.

we're running Laravel in kubernetes in production and got around 90k of errors in sentry a few hours ago.
Screenshot 2022-04-07 at 16 12 56

Most of these errors (but not solely) occurred on the livenessProbe which points to /api/v1/simple-status which is just a simple json response.

final class StatusController extends Controller
{
   ...
    public function simpleStatus(): JsonResponse
    {
        return $this->response->json([
            'status' => self::STATUS_OK,
        ]);
    }

Running:

  • php: 8.1.4
  • laravel/framework v8.83.6
  • monolog/monolog 2.4.0
and our `logging.php` declare(strict_types=1);

use Modules\Core\Enum\LogChannel;
use Modules\Core\Enum\LoggerType;
use Modules\Core\Logging\Drivers\ObjectstoreLogDriver;
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;

return [

/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the 'channels' configuration array.
|
*/

LoggerType::DEFAULT => env('LOG_CHANNEL', LogChannel::SINGLE), // in production is "stack"

/*
|--------------------------------------------------------------------------
| Log Channel per log type
|--------------------------------------------------------------------------
|
| This option defines the log channel for each custom logger type
*/

LoggerType::DEFAULT_CONTEXT_AWARE => env('CONTEXT_AWARE_LOG_CHANNEL', LogChannel::SINGLE),
LoggerType::CONNECTIONS => env('CONNECTION_LOG_CHANNEL', LogChannel::SINGLE),

/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: 'single', 'daily', 'slack', 'syslog',
|                    'errorlog', 'monolog',
|                    'custom', 'stack'
|
*/

'channels' => [
    LogChannel::STACK => [
        'driver' => 'stack',
        'channels' => ['stderr', 'stdout'],
    ],

    LogChannel::SINGLE => [
        'driver' => 'single',
        'path' => storage_path('logs/laravel.log'),
        'level' => 'debug',
    ],

    LogChannel::STDERR => [
        'driver' => 'monolog',
        'level' => 'error',
        'handler' => StreamHandler::class,
        'formatter' => env('LOG_STDERR_FORMATTER'), // in production is "Monolog\Formatter\JsonFormatter"
        'with' => [
            'stream' => 'php://stderr',
        ],
    ],

    LogChannel::STDOUT => [
        'driver' => 'monolog',
        'level' => 'debug',
        'handler' => StreamHandler::class,
        'formatter' => env('LOG_STDOUT_FORMATTER'), // in production is "Monolog\Formatter\JsonFormatter"
        'with' => [
            'stream' => 'php://stdout',
        ],
    ],

    LogChannel::NULL => [
        'driver' => 'monolog',
        'handler' => NullHandler::class,
    ],

    LogChannel::EMERGENCY => [
        'path' => storage_path('logs/laravel.log'),
    ],
],

];

There's little more information why this error would have occurred. Since the pods have been killed by kubernetes any other logs which might have ended up in laravel.log (due to the emergency logger) are gone

*fyi: here the same error is reported: #41070 with the notice This will be fixed in the next patch release.

@Levivb
Copy link

Levivb commented Apr 7, 2022

And a few of the stacktraces:

Trace 1 Symfony\Component\ErrorHandler\Error\FatalError: Uncaught Error: Class "Illuminate\Log\Logger" not found in /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:180 Stack trace: #0 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger() #1 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get('deprecations') #2 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager->driver('deprecations') #3 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(104): Illuminate\Log\LogManager->channel('deprecations') #4 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\Foundation\Bootstrap\HandleExceptions->handleDeprecation('Return type of ...', '/srv/app/vendor...', 866) #5 /srv/app/vendor/composer/ClassLoader.php(571): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of ...', '/srv/app/vendor...', 866) #6 /srv/app/vendor/composer/ClassLoader.php(571): include('/srv/app/vendor...') #7 /srv/app/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/srv/app/vendor...') #8 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): Composer\Autoload\ClassLoader->loadClass('Illuminate\\Log\\...') #9 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger() #10 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get('stack') #11 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager->driver() #12 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\Log\LogManager->error('Class "Illumina...', Array) #13 /srv/app/app/Exceptions/Handler.php(88): Illuminate\Foundation\Exceptions\Handler->report(Object(Error)) #14 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(165): App\Exceptions\Handler->report(Object(Error)) #15 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #16 {main} thrown #0 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): null
Trace 2 Error: Class "Illuminate\Log\Logger" not found #17 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): Illuminate\Log\LogManager::createEmergencyLogger #16 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get #15 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver #14 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager::channel #13 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(104): Illuminate\Foundation\Bootstrap\HandleExceptions::handleDeprecation #12 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\Foundation\Bootstrap\HandleExceptions::handleError #11 /vendor/composer/ClassLoader.php(571): include #10 /vendor/composer/ClassLoader.php(571): Composer\Autoload\includeFile #9 /vendor/composer/ClassLoader.php(428): Composer\Autoload\ClassLoader::loadClass #8 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): Illuminate\Log\LogManager::createEmergencyLogger #7 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get #6 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver #5 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager::error #4 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\Foundation\Exceptions\Handler::report #3 /app/Exceptions/Handler.php(88): App\Exceptions\Handler::report #2 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(415): Illuminate\Foundation\Http\Kernel::reportException #1 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(113): Illuminate\Foundation\Http\Kernel::handle #0 /public/index.php(38): null
Trace 3 Error: Class "Illuminate\Log\Logger" not found #42 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): Illuminate\Log\LogManager::createEmergencyLogger #41 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get #40 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver #39 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager::channel #38 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(104): Illuminate\Foundation\Bootstrap\HandleExceptions::handleDeprecation #37 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\Foundation\Bootstrap\HandleExceptions::handleError #36 /vendor/composer/ClassLoader.php(571): include #35 /vendor/composer/ClassLoader.php(571): Composer\Autoload\includeFile #34 /vendor/composer/ClassLoader.php(428): Composer\Autoload\ClassLoader::loadClass #33 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(180): Illuminate\Log\LogManager::createEmergencyLogger #32 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get #31 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver #30 /vendor/maximum/request-tracking/src/Code/Providers/RequestTrackingServiceProvider.php(32): Maximum\RequestTracking\Providers\RequestTrackingServiceProvider::Maximum\RequestTracking\Providers\{closure} #29 /vendor/laravel/framework/src/Illuminate/Container/Container.php(873): Illuminate\Container\Container::build #28 /vendor/laravel/framework/src/Illuminate/Container/Container.php(758): Illuminate\Container\Container::resolve #27 /vendor/laravel/framework/src/Illuminate/Foundation/Application.php(851): Illuminate\Foundation\Application::resolve #26 /vendor/laravel/framework/src/Illuminate/Container/Container.php(694): Illuminate\Container\Container::make #25 /vendor/laravel/framework/src/Illuminate/Foundation/Application.php(836): Illuminate\Foundation\Application::make #24 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(156): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure} #23 /vendor/maximum/request-tracking/src/Code/Http/Middleware/RequestId.php(45): Maximum\RequestTracking\Http\Middleware\RequestId::handle #22 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure} #21 /vendor/laravel-modules/core/src/Code/Http/Middleware/ErrorReporterContext.php(25): Modules\Core\Http\Middleware\ErrorReporterContext::handle #20 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure} #19 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline::then #18 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(723): Illuminate\Routing\Router::runRouteWithinStack #17 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(698): Illuminate\Routing\Router::runRoute #16 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\Routing\Router::dispatchToRoute #15 /vendor/laravel/framework/src/Illuminate/Routing/Router.php(651): Illuminate\Routing\Router::dispatch #14 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\Foundation\Http\Kernel::Illuminate\Foundation\Http\{closure} #13 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure} #12 /vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestIpMiddleware.php(45): Sentry\Laravel\Http\SetRequestIpMiddleware::handle #11 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure} #10 /vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestMiddleware.php(42): Sentry\Laravel\Http\SetRequestMiddleware::handle #9 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure} #8 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Foundation\Http\Middleware\TransformsRequest::handle #7 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TrimStrings::handle #6 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure} #5 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Foundation\Http\Middleware\ValidatePostSize::handle #4 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure} #3 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline::then #2 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Foundation\Http\Kernel::sendRequestThroughRouter #1 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel::handle #0 /public/index.php(38): null
Trace 4 Symfony\Component\ErrorHandler\Error\FatalError: Uncaught Error: Class "Monolog\Handler\StreamHandler" not found in /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:175 Stack trace: #0 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger() #1 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get('deprecations') #2 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager->driver('deprecations') #3 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(104): Illuminate\Log\LogManager->channel('deprecations') #4 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\Foundation\Bootstrap\HandleExceptions->handleDeprecation('Return type of ...', '/srv/app/vendor...', 866) #5 /srv/app/vendor/composer/ClassLoader.php(571): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of ...', '/srv/app/vendor...', 866) #6 /srv/app/vendor/composer/ClassLoader.php(571): include('/srv/app/vendor...') #7 /srv/app/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/srv/app/vendor...') #8 /srv/app/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php(26): Composer\Autoload\ClassLoader->loadClass('Monolog\\Handler...') #9 /srv/app/vendor/composer/ClassLoader.php(571): include('/srv/app/vendor...') #10 /srv/app/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/srv/app/vendor...') #11 /srv/app/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(27): Composer\Autoload\ClassLoader->loadClass('Monolog\\Handler...') #12 /srv/app/vendor/composer/ClassLoader.php(571): include('/srv/app/vendor...') #13 /srv/app/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/srv/app/vendor...') #14 /srv/app/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php(26): Composer\Autoload\ClassLoader->loadClass('Monolog\\Handler...') #15 /srv/app/vendor/composer/ClassLoader.php(571): include('/srv/app/vendor...') #16 /srv/app/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/srv/app/vendor...') #17 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): Composer\Autoload\ClassLoader->loadClass('Monolog\\Handler...') #18 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager->createEmergencyLogger() #19 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager->get('stack') #20 /srv/app/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager->driver() #21 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\Log\LogManager->error('Class "Monolog\\...', Array) #22 /srv/app/app/Exceptions/Handler.php(88): Illuminate\Foundation\Exceptions\Handler->report(Object(Error)) #23 /srv/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(165): App\Exceptions\Handler->report(Object(Error)) #24 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error)) #25 {main} thrown #0 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): null

@Levivb
Copy link

Levivb commented Apr 13, 2022

Is there anyone with more information regarding this? we're burning through hundreds of thousand of errors in Sentry, effectively nuking our budget.

So far there's absolutely no indication what might cause this behaviour. But some (but not all) sites we deploy with a release containing php 8.1, that site also starts generating numerous errors

within one hour 72.000 errors occurred from one single application on an api endpoint solely returning a static json response with this stacktrace:

Error: Class "Monolog\Handler\StreamHandler" not found
#36 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): Illuminate\Log\LogManager::createEmergencyLogger
#35 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get
#34 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver
#33 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(101): Illuminate\Log\LogManager::channel
#32 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(104): Illuminate\Foundation\Bootstrap\HandleExceptions::handleDeprecation
#31 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(71): Illuminate\Foundation\Bootstrap\HandleExceptions::handleError
#30 /vendor/composer/ClassLoader.php(571): include
#29 /vendor/composer/ClassLoader.php(571): Composer\Autoload\includeFile
#28 /vendor/composer/ClassLoader.php(428): Composer\Autoload\ClassLoader::loadClass
#27 /vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php(26): include
#26 /vendor/composer/ClassLoader.php(571): Composer\Autoload\includeFile
#25 /vendor/composer/ClassLoader.php(428): Composer\Autoload\ClassLoader::loadClass
#24 /vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(27): include
#23 /vendor/composer/ClassLoader.php(571): Composer\Autoload\includeFile
#22 /vendor/composer/ClassLoader.php(428): Composer\Autoload\ClassLoader::loadClass
#21 /vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php(26): include
#20 /vendor/composer/ClassLoader.php(571): Composer\Autoload\includeFile
#19 /vendor/composer/ClassLoader.php(428): Composer\Autoload\ClassLoader::loadClass
#18 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(175): Illuminate\Log\LogManager::createEmergencyLogger
#17 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(129): Illuminate\Log\LogManager::get
#16 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(112): Illuminate\Log\LogManager::driver
#15 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(590): Illuminate\Log\LogManager::error
#14 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(252): Illuminate\Foundation\Exceptions\Handler::report
#13 /app/Exceptions/Handler.php(88): App\Exceptions\Handler::report
#12 /vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(49): Illuminate\Routing\Pipeline::handleException
#11 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(172): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#10 /vendor/sentry/sentry-laravel/src/Sentry/Laravel/Http/SetRequestMiddleware.php(42): Sentry\Laravel\Http\SetRequestMiddleware::handle
#9 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#8 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Foundation\Http\Middleware\TransformsRequest::handle
#7 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\Foundation\Http\Middleware\TrimStrings::handle
#6 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#5 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Foundation\Http\Middleware\ValidatePostSize::handle
#4 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
#3 /vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\Pipeline\Pipeline::then
#2 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\Foundation\Http\Kernel::sendRequestThroughRouter
#1 /vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\Foundation\Http\Kernel::handle
#0 /public/index.php(38): null

@Levivb
Copy link

Levivb commented Apr 20, 2022

It seems to be related to a bug in php's opcache: php/php-src#8164

Will leave a comment there tomorrow

@jackwh
Copy link
Contributor

jackwh commented May 9, 2022

Hey @Levivb, I've been chasing my tail trying to solve this same issue for 4 days now. Seen a few of your comments elsewhere about this, sure has been a fun one to debug 🙃 Did you have any luck trying this with 8.1.6 RC1?

For anyone else who comes across this, it's definitely a PHP opcache bug — I've stumbled across 5 or 6 different discussions from various PHP projects all reporting similar issues, nobody seems able to solve it, but all the clues point back to the opcache. I had no idea what the error even was at first, as no logs were being written (emergency logger unavailable due to the faulty opcache resolution). I only found out after installing New Relic which was able to hook in at a lower level (though their telemetry client seems to be affected by this for many people too: newrelic/newrelic-php-agent#387 )

Supposedly PHP 8.1.6 fixes this via php/php-src#8297 — I think it's due to be released properly on May 12th.

@nunomaduro — hopefully 8.1.6 can be made available as a patch upgrade on Laravel Forge ASAP once released? Not sure how long minor versions normally take to become available, but it would be much appreciated 🤞 Thank you!

@Levivb
Copy link

Levivb commented May 9, 2022

Hey @jackwh yea, got quite an amount of time into tracking this thing 😅 . Most of the currently relevant information is stowed away in the thread at php/php-src#8164. It just so happens that I posted in there earlier today stating I would try out 8.1.6RC1. Currently running 8.1.6RC1-fpm in one of the sites in production which as of yet hasn't gone haywire 🤞 (although it might take a couple of days).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants