phptools-docs icon indicating copy to clipboard operation
phptools-docs copied to clipboard

Child processes are orphaned after stopping debug session

Open eswolinsky3241 opened this issue 10 months ago • 8 comments

Hello, I have the DEVSENSE PHP Vscode extension version v1.45.15272 installed and am using the "Launch built-in server" debug configuration to debug my PHP web app in VSCode. My app requires serving some static content while the backend script is still running so that I can incrementally flush output to the browser for my users, so I need to set the PHP_CLI_SERVER_WORKERS environment variable to pre-fork additional request handlers. My launch configuration looks like this:

{
"version": "0.2.0",
    "configurations": [
        {
            "name": "Launch built-in server test",
            "type": "php",
            "request": "launch",
            "runtimeArgs": [
                "-S",
                "localhost:8000",
                "-t",
                "."
            ],
            "env": {
                "PHP_CLI_SERVER_WORKERS": "4"
            },
            "port": 9003,
            "serverReadyAction": {
                "action": "openExternally"
            }
        }
}

When I start the debug session, I can see that the 4 workers are children of the main php process:

$ pstree -pa | grep dxdebug | grep php
  |   |   |   |       |   |-php,79708 -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.mode=develop,debug ...
  |   |   |   |       |   |   |-php,79709 -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.mode=develop,debug ...
  |   |   |   |       |   |   |-php,79710 -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.mode=develop,debug ...
  |   |   |   |       |   |   |-php,79711 -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.mode=develop,debug ...
  |   |   |   |       |   |   `-php,79712 -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.mode=develop,debug ...

I then stop the debug session. Now the 4 workers are still running, but have been orphaned. This is not the case if I manually start the server and workers from the command line or through a VSCode task:

$ pstree -pa | grep dxdebug | grep php
  |-php,79709 -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.mode=develop,debug ...
  |-php,79710 -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.mode=develop,debug ...
  |-php,79711 -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.mode=develop,debug ...
  |-php,79712 -dxdebug.client_host=127.0.0.1 -dxdebug.client_port=9003 -dxdebug.mode=develop,debug ...

This is a problem because I have to manually kill these to prevent them from taking up resources. Is this an issue with the PHP extension or a larger issue with how VSCode's debugger does process handling?

eswolinsky3241 avatar Apr 22 '24 12:04 eswolinsky3241

Hello,

Thank you for bringing this to our attention. I think instead of killing the process forcibly we should handle it more gently. We've made the modification and the update will be available in the next pre-release. I will ping you when the update is available.

Thanks

Miloslav avatar Apr 24 '24 15:04 Miloslav

Thank you!

eswolinsky3241 avatar Apr 24 '24 19:04 eswolinsky3241

The fix is in the latest pre-release now, may I ask if it solved it for you?

Miloslav avatar May 01 '24 11:05 Miloslav

Hi, I'm unfortunately having the same issue on v1.45.15341 (pre-release)

eswolinsky3241 avatar May 01 '24 18:05 eswolinsky3241

Thanks for trying, I will prepare a test environment to replicate this on our machines. Hopefully, fix it for good.

Miloslav avatar May 02 '24 08:05 Miloslav

Fixed in the latest version 1.46, please let us know if that works for you.

jakubmisek avatar May 08 '24 14:05 jakubmisek

It appears it still doesn't work, I guess the required script files weren't included in the release package. I will take a look at it

Miloslav avatar May 08 '24 15:05 Miloslav

Hi confirmed that this is still an issue on v1.46.15395

eswolinsky3241 avatar May 08 '24 20:05 eswolinsky3241

Hi, this has been fixed, it will be available in the next pre-release.

Thanks again!

Miloslav avatar May 13 '24 12:05 Miloslav