DEVSENSE / phptools-docs

PHP Tools public content
Apache License 2.0
75 stars 9 forks source link

Child processes are orphaned after stopping debug session #542

Closed eswolinsky3241 closed 1 month ago

eswolinsky3241 commented 2 months ago

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?

Miloslav commented 2 months ago

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

eswolinsky3241 commented 2 months ago

Thank you!

Miloslav commented 2 months ago

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

eswolinsky3241 commented 2 months ago

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

Miloslav commented 2 months ago

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

jakubmisek commented 1 month ago

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

Miloslav commented 1 month ago

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

eswolinsky3241 commented 1 month ago

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

Miloslav commented 1 month ago

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

Thanks again!