itsgoingd / itsgoingd/clockwork

[Laravel + Sail] Bug: gzdecode(): data error

Open
#745 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
6k
Forks
333
Avg merge
5m
Merged PRs (30d)
1

Description

Description:

When trying to fetch profiles for a Laravel application running with Sail (Runtime Version 8.3) something is going wrong with when trying to decompress the cachegrind profile archive in XdebugDataSource.

Steps to reproduce:
# create a new project
laravel new --no-interaction -- test-case
cd ./test-case

# Add clockwork
composer require --dev itsgoingd/clockwork

# install sail
php artisan sail:install --with=none --php=8.3

# Add custom xdebug configuration
mkdir ./.docker
{
    echo '[xdebug]'
    echo 'xdebug.mode=${XDEBUG_MODE}'
    echo 'xdebug.start_with_request = trigger'
    echo 'xdebug.profiler_output_name = cachegrind.out.%u.%r'
} >> ./.docker/20-xdebug.ini

# Add custom xdebug config to mounted volumes
awk 'NR==22{print "            - './.docker/20-xdebug.ini:/etc/php/8.3/conf.d/20-xdebug.ini'"}1' ./docker-compose.yml > ./tmp && mv ./tmp ./docker-compose.yml

# Configure SAIL_XDEBUG_MODE=profile
echo "SAIL_XDEBUG_MODE=profile" >> .env

./vendor/bin/sail up -d

Then open up clockwork and in another tab localhost.

Enable the profiler for / and reload to capture the request using profiling.

The error should show up in storage/logs/laravel.log as well as in your browser's dev tools.

Stack Trace:
[2025-08-20 10:24:10] local.ERROR: gzdecode(): data error {"exception":"[object] (ErrorException(code: 0): gzdecode(): data error at /var/www/html/vendor/itsgoingd/clockwork/Clockwork/DataSource/XdebugDataSource.php:25)
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(258): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}()
#2 /var/www/html/vendor/itsgoingd/clockwork/Clockwork/DataSource/XdebugDataSource.php(25): gzdecode()
#3 /var/www/html/vendor/itsgoingd/clockwork/Clockwork/Clockwork.php(120): Clockwork\\DataSource\\XdebugDataSource->extend()
#4 /var/www/html/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkSupport.php(67): Clockwork\\Clockwork->extendRequest()
#5 /var/www/html/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkSupport.php(87): Clockwork\\Support\\Laravel\\ClockworkSupport->getData()
#6 /var/www/html/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkController.php(40): Clockwork\\Support\\Laravel\\ClockworkSupport->getExtendedData()
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): Clockwork\\Support\\Laravel\\ClockworkController->getExtendedData()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(43): Illuminate\\Routing\\Controller->callAction()
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(265): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(211): Illuminate\\Routing\\Route->runController()
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(822): Illuminate\\Routing\\Route->run()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(821): Illuminate\\Pipeline\\Pipeline->then()
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(800): Illuminate\\Routing\\Router->runRouteWithinStack()
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(764): Illuminate\\Routing\\Router->runRoute()
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(753): Illuminate\\Routing\\Router->dispatchToRoute()
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(200): Illuminate\\Routing\\Router->dispatch()
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#21 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Http\\Middleware\\ValidatePostSize->handle()
#28 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(109): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(48): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#31 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Http\\Middleware\\HandleCors->handle()
#32 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(58): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#34 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#35 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Foundation\\Http\\Middleware\\InvokeDeferredCallbacks->handle()
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePathEncoding.php(26): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#37 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(219): Illuminate\\Http\\Middleware\\ValidatePathEncoding->handle()
#38 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#39 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(175): Illuminate\\Pipeline\\Pipeline->then()
#40 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(144): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#41 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1219): Illuminate\\Foundation\\Http\\Kernel->handle()
#42 /var/www/html/public/index.php(20): Illuminate\\Foundation\\Application->handleRequest()
#43 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php(23): require_once('...')
#44 {main}
"} 

What's interesting is, that the gz archive seems to be in tact.

When you open up a shell using ./vendor/bin/sail bash, then run an interactive PHP session using php -a and manually perform what the XdebugDataSource does:

$archiveData = file_get_contents('/tmp/cachegrind.out.15.gz');
$profileData = gzdecode($archiveData);
echo $profileData;

It just works as intended.

LMK if you need further information and thanks for the awesome tool!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Clockwork/DataSource/XdebugDataSource.php at the gzdecode() call and reproduce the Laravel Sail PHP 8.3 profiling flow from the issue. Compare that path with the interactive PHP commands that successfully decode /tmp/cachegrind.out.15.gz. Done means profiling through Clockwork no longer logs the gzdecode() data error while the captured profile remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, laravel, php
Domain
backend, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.