opcodesio/log-viewer

unserialize(): Error at offset 2 of 11 bytes Error in 3.1.1

Brandutchmen opened this issue ยท 18 comments

Not sure what might be causing this. I'm trying to upgrade from 2.3

Full Stacktrace
unserialize(): Error at offset 2 of 11 bytes {"userId":1,"exception":"[object] (ErrorException(code: 0): unserialize(): Error at offset 2 of 11 bytes at /var/www/html/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php:403)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(254): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}()
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php(403): unserialize()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Cache/DatabaseStore.php(123): Illuminate\\Cache\\DatabaseStore->unserialize()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(99): Illuminate\\Cache\\DatabaseStore->get()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(353): Illuminate\\Cache\\Repository->get()
#6 /var/www/html/vendor/opcodesio/log-viewer/src/Concerns/LogIndex/CanCacheIndex.php(69): Illuminate\\Support\\Facades\\Facade::__callStatic()
#7 /var/www/html/vendor/opcodesio/log-viewer/src/Concerns/LogIndex/CanSplitIndexIntoChunks.php(38): Opcodes\\LogViewer\\LogIndex->getChunkDataFromCache()
#8 /var/www/html/vendor/opcodesio/log-viewer/src/LogIndex.php(41): Opcodes\\LogViewer\\LogIndex->getCurrentChunk()
#9 /var/www/html/vendor/opcodesio/log-viewer/src/Readers/IndexedLogReader.php(107): Opcodes\\LogViewer\\LogIndex->addToIndex()
#10 /var/www/html/vendor/opcodesio/log-viewer/src/Readers/IndexedLogReader.php(27): Opcodes\\LogViewer\\Readers\\IndexedLogReader->scan()
#11 /var/www/html/vendor/opcodesio/log-viewer/src/Concerns/LogReader/KeepsFileHandle.php(55): Opcodes\\LogViewer\\Readers\\IndexedLogReader->onFileOpened()
#12 /var/www/html/vendor/opcodesio/log-viewer/src/Concerns/LogReader/KeepsFileHandle.php(29): Opcodes\\LogViewer\\Readers\\BaseLogReader->openFile()
#13 /var/www/html/vendor/opcodesio/log-viewer/src/Readers/IndexedLogReader.php(72): Opcodes\\LogViewer\\Readers\\BaseLogReader->prepareFileForReading()
#14 /var/www/html/vendor/opcodesio/log-viewer/src/Http/Controllers/LogsController.php(65): Opcodes\\LogViewer\\Readers\\IndexedLogReader->scan()
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(46): Opcodes\\LogViewer\\Http\\Controllers\\LogsController->index()
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(259): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(799): Illuminate\\Routing\\Route->run()
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#20 /var/www/html/vendor/opcodesio/log-viewer/src/Http/Middleware/ForwardRequestToHostMiddleware.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#21 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Opcodes\\LogViewer\\Http\\Middleware\\ForwardRequestToHostMiddleware->handle()
#22 /var/www/html/vendor/opcodesio/log-viewer/src/Http/Middleware/AuthorizeLogViewer.php(13): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Opcodes\\LogViewer\\Http\\Middleware\\AuthorizeLogViewer->handle()
#24 /var/www/html/vendor/opcodesio/log-viewer/src/Http/Middleware/EnsureFrontendRequestsAreStateful.php(38): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Opcodes\\LogViewer\\Http\\Middleware\\EnsureFrontendRequestsAreStateful->Opcodes\\LogViewer\\Http\\Middleware\\{closure}()
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#28 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\StartSession->handle()
#31 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#32 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#34 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#35 /var/www/html/vendor/opcodesio/log-viewer/src/Http/Middleware/EnsureFrontendRequestsAreStateful.php(31): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(162): Opcodes\\LogViewer\\Http\\Middleware\\EnsureFrontendRequestsAreStateful->Opcodes\\LogViewer\\Http\\Middleware\\{closure}()
#37 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#38 /var/www/html/vendor/opcodesio/log-viewer/src/Http/Middleware/EnsureFrontendRequestsAreStateful.php(37): Illuminate\\Pipeline\\Pipeline->then()
#39 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Opcodes\\LogViewer\\Http\\Middleware\\EnsureFrontendRequestsAreStateful->handle()
#40 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#41 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(798): Illuminate\\Pipeline\\Pipeline->then()
#42 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(777): Illuminate\\Routing\\Router->runRouteWithinStack()
#43 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(741): Illuminate\\Routing\\Router->runRoute()
#44 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(730): Illuminate\\Routing\\Router->dispatchToRoute()
#45 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch()
#46 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#47 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#48 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#49 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#50 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#51 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#52 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#53 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#54 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#55 /var/www/html/app/Http/Middleware/CheckForReadOnlyMode.php(51): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#56 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): App\\Http\\Middleware\\CheckForReadOnlyMode->handle()
#57 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(89): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#58 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#59 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#60 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#61 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#62 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then()
#63 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#64 /var/www/html/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
#65 /var/www/html/server.php(19): require_once('...')
#66 {main}
"}

hey @Brandutchmen thanks for the report!

First of all, what database are you using? Please include the version as well. I haven't tested the Log Viewer with database as cache driver.

In the meantime, could you switch Log Viewer to one of the other caching mechanisms, such as file or redis ? Just add it to your .env file, like so:

LOG_VIEWER_CACHE_DRIVER=file

I'll test the database cache driver later.

Good call.

Using either redis or file for LOG_VIEWER_CACHE_DRIVER works.

Plus, I should be using Redis for this anyway...

Thank you!

Screenshot 2023-08-31 at 1 11 13 PM

Attached is the error from using the database as a cache driver

@Brandutchmen hey, what database were you using? MySQL, PostgreSQL, MariaDB, SingleStore? And what version? Just so I'm replicating in the similar environment.

@arukompas, Mysql 8.
Docker image mysql/mysql-server:8.0

I was also not able to get database cache driver so I just switched to file.

same issue

hey @Brandutchmen , there were improvements in latest Log Viewer, namely v3.1.8, could you try it again with database cache driver?

i upgrade to newest version 3.1.9 but still have this error
every time after access to route /log-viewer , and i access to another route after that it happened again.

hey @MNhat0308 , are you using a database cache driver? Which database type and version are you using?

Also, if you switch to a different cache driver, such as file or redis, does it then work properly?

hi @arukompas , so i'm using file cache driver and postgresql version 13

Hello @MNhat0308, I'm facing the same issue. Could you please tell me how you resolved it?

hi @irtzamazhar , i think you should upgrade to last version, i'm not using this anymore, so i don't know how to fix it/

@arukompas could you please help me to resolve this problem?

@irtzamazhar please share the Log Viewer version, PHP version, Laravel version, config/log-viewer.php and what other packages you're using.

Also, which cache driver are you using? If you switch to redis or file driver, does the issue disappear?

@irtzamazhar If you're not using Sanctum, you have to disable the EnsureFrontendRequestsAreStateful middleware in config/log-viewer.php. This middleware utilizes Sanctum's encrypt_cookies middleware if available; otherwise, it defaults to Laravel's EncryptCookies middleware. In Laravel's EncryptCookies middleware, serialize is false by default.

In middle EncryptCookies file set protected static $serialize = false; to false and it work well