filp / whoops

PHP errors for cool kids
http://filp.github.io/whoops/
MIT License
13.18k stars 603 forks source link

Occasional errors with zlib.output_compression = On #704

Open kexxt opened 3 years ago

kexxt commented 3 years ago

Hello, occasionally I experience this error when I should not be seeing any whoops-related pages.

Uncaught Whoops\Exception\ErrorException: ob_end_clean(): failed to discard buffer of zlib output compression (1)

I've identified the issue is caused by Run.php line 396:

while ($this->system->getOutputBufferLevel() > 0) {
    $this->system->endOutputBuffering();
}

I am also submitting a PR with a very simple fix

kexxt commented 3 years ago

Specifically the problem occurs when ob_end_clean() is called while ob_get_length() is zero. By checking for a length > 0, we avoid the aforementioned error. When I tested this fix I stopped seeing the error and was able to resume debugging my own application (I was actually supposed to see a whoops page for something different.