View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0002168||Xdebug||Uncategorized||public||2023-03-30 05:50||2023-08-01 10:13|
|Summary||0002168: Flush not guaranteed|
This happened on a PHP project without any framework (such as Laravel) on Apache and PHP 8.1 FPM.
I am working on a PHP site that had the odd behaviour of returning empty content to an AJAX request randomly but then I found a specific value (part of JSON POST) that would consistently cause an empty response. Debugging the handler showed no sign of any problem. The JSON response was echoed in the very last line of the code and after that destructors were called. By adding flush() at the end of the script, the problem was solved. At first I suspected a destructor caused an exception which might then cause a flush not to be done. I switched on tracing and found the names of destructors and commented them out (commented flush out as well). This did not fix the problem and then I disabled XDebug after which the PHP response was returned as expected without fail. The moment I enabled XDebug again, the problem persisted again.
This problem is not consistent. The value I mentioned earlier was a numeric value (ID number) and the only time I was able to consistently cause the problem was for a specific ID that happened to start with 2 zeros. On other values the problem happened sporadically and sometimes not at all. My best guess is that there is a specific state in XDebug which prevents a flush once the request is complete. Best guess would be that an exception is thrown in XDebug module which prevents PHP from calling the flush.
|Steps To Reproduce|
This issue is so sporadic that I believe there is very little chance anyone else can reproduce it consistently. Since I seem to have a silver bullet, I can help by generating an XDebug module log if someone can guide me on how to do this.
|Operating System||Ubuntu 22.04|
I am not sure if we'll ever find this out... but Xdebug should not mess with flushing at all.
If this is still a problem for you, an Xdebug log file while debugging (