ddev / ddev

Docker-based local PHP+Node.js web development environments
https://ddev.com
Apache License 2.0
2.47k stars 585 forks source link

`ddev xdebug toggle` and `ddev xdebug status` hang if xdebug is enabled and an IDE is listening for xdebug #6191

Open rfay opened 1 month ago

rfay commented 1 month ago

Expected Behavior

ddev xdebug status and ddev xdebug toggle should "just work" no matter what the situation.

Actual Behavior

If an IDE is listening on port 9003, and xdebug is enabled, both of these hang.

Steps To Reproduce

  1. Start PhpStorm and make it listen.
  2. ddev xdebug on
  3. ddev xdebug status or ddev xdebug toggle will hang

Anything else?

More detail and ideas in

We can probably safely use php --version | grep -i xdebug for this more safely and prevent this problem.

It would also be trivial to change to XDEBUG_MODE=off php -r 'echo ini_get("xdebug.mode");', which would work for Xdebug 3, it might not be right for Xdebug 2.

tyler36 commented 1 month ago

Unable to replicate on VSCode. Perhaps we can replace "IDE" with "PHPstorm" in the title and description?

Test

  1. Open DDEV project in VScode
  2. Start Debug listener in VScode
  3. Toggle xdebug in DDEV:
$ ddev xdebug toggle
Building project images... 
...
Enabled xdebug
  1. VSCode continues to function
    • Can open new files
    • Update files
    • navigate around menu
    • enter commands in terminal

DDEV: 1.23.0 VSCode: 1.89.1 VSCode xdebug.php-debug 1.34.0

rfay commented 1 month ago

The problem happens when you:

tyler36 commented 1 month ago

OK,

Test

  1. Create break point
  2. Turn on listener in Vscode
  3. Turn on xdebug
$ ddev xdebug
Enabled xdebug
  1. Confirm breakpoint is it. Continue through to allow page to load.
  2. Toggle xdebug
$ ddev xdebug toggle
Disabled xdebug
  1. No problems.
  2. Turn on xdebug
$ ddev xdebug
Enabled xdebug
  1. Confirm breakpoint is it.
  2. While on breakpoint, toggle xdebug
$ ddev xdebug toggle
Disabled xdebug
  1. Vscode removes debugging info. Site displays as "502 Bad Gateway", but displays correctly on refresh. Things seem to work as expected.
rfay commented 1 month ago

Thanks for the careful testing. I doubt that this is different between PhpStorm and vscode, but it may very well be different between macOS (where I tested) and Win/WSL2.

In my testing I didn't exercise the website or breakpoints at all. I just ddev xdebug and then ddev xdebug status or ddev xdebug toggle

tyler36 commented 1 month ago

Just tried on Gitpod to remove the OS variable. Running ddev xdebug and then ddev xdebug status then ddev xdebug toggle doesn't seem cause any hangs in the Gitpod VScode or it's terminal.

Can anyone replicate it on Gitpod or Codespaces?