xdebug / vscode-php-debug

PHP Debug Adapter for Visual Studio Code 🐞⛔
MIT License
778 stars 178 forks source link

Invalid Debug Adapter #949

Closed andrew-laughlin closed 1 month ago

andrew-laughlin commented 9 months ago

PHP version: 8.3 Xdebug version: 3.3 VS Code extension version: 1.34.0

Your launch.json:

    {
        "name": "Listen for Xdebug",
        "type": "php",
        "request": "launch",
        "port": 9003
    }

Xdebug php.ini config: [xdebug] zend_extension = /home/user/.config/Local/lightning-services/php-8.3.0+1/bin/linux/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so xdebug.mode=debug,develop xdebug.client_port=9003 xdebug.start_with_request=yes xdebug.discover_client_host=yes

Xdebug logfile (from setting xdebug.log in php.ini): VS Code extension logfile (from setting "log": true in launch.json):

Code snippet to reproduce:

When stopping a debugging session (by clicking stop on the debug bar), the following is consistently displayed in the VSCode output window (with "Extension Host") selected.

2024-01-08 19:16:38.585 [error] Error: Invalid debug adapter at v.m (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1553:95) at v.$acceptDAError (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1552:7629) at m.S (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1561:18889) at m.Q (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1561:18655) at m.M (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1561:17748) at m.L (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1561:16827) at o.value (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1561:15630) at u.y (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:87:1902) at u.fire (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:87:2119) at s.fire (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:616:14449) at x.onmessage (vscode-file://vscode-app/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1657:7802)

zobo commented 8 months ago

Hi. Are you on linux or on mac?

Does this happen even if no debug session is established? By that I mean you start Listen for Xdebug and then click stop before any PHP script gets run.

It'd be really helpful if you could provide "log":true debug contents from the Debug Console.

andrew-laughlin commented 8 months ago

Thanks for the quick response. I'm on Debian 11.

Does this happen even if no debug session is established? By that I mean you start Listen for Xdebug and then click stop before any PHP script gets run.

That's correct. If I start, then stop the debug session, the "Invalid Debug Adapter" error is shown twice in the output window. Below is the debug console output. In this session, there is 1 breakpoint set.


Listening on { address: '::', family: 'IPv6', port: 9003 }
<- launchResponse
Response { seq: 0, type: 'response', request_seq: 2, command: 'launch', success: true }
<- initializedEvent
InitializedEvent { seq: 0, type: 'event', event: 'initialized' }
-> setBreakpointsRequest
{ command: 'setBreakpoints',
  arguments:
   { source:
      { name: 'Config.php',
        path:
         '/home/user/Local Sites/site4/app/public/wp-content/plugins/FmcsaConnector/src/Config.php' },
     lines: [ 12 ],
     breakpoints: [ { line: 12 } ],
     sourceModified: false },
  type: 'request',
  seq: 3 }
<- setBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 3,
  command: 'setBreakpoints',
  success: true,
  body:
   { breakpoints:
      [ { verified: true,
          line: 12,
          source:
           { name: 'Config.php',
             path:
              '/home/user/Local Sites/site4/app/public/wp-content/plugins/FmcsaConnector/src/Config.php' },
          id: 1 } ] } }
-> setFunctionBreakpointsRequest
{ command: 'setFunctionBreakpoints',
  arguments: { breakpoints: [] },
  type: 'request',
  seq: 4 }
<- setFunctionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 4,
  command: 'setFunctionBreakpoints',
  success: true,
  body: { breakpoints: [] } }
-> setExceptionBreakpointsRequest
{ command: 'setExceptionBreakpoints',
  arguments: { filters: [ 'Error' ] },
  type: 'request',
  seq: 5 }
<- setExceptionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 5,
  command: 'setExceptionBreakpoints',
  success: true,
  body: { breakpoints: [ { verified: true, id: 2 } ] } }
-> configurationDoneRequest
{ command: 'configurationDone', type: 'request', seq: 6 }
<- configurationDoneResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 6,
  command: 'configurationDone',
  success: true }
-> threadsRequest
{ command: 'threads', type: 'request', seq: 7 }
<- threadsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 7,
  command: 'threads',
  success: true,
  body: { threads: [] } }
-> disconnectRequest
{ command: 'disconnect',
  arguments: { restart: false, terminateDebuggee: true },
  type: 'request',
  seq: 8 }
<- disconnectResponse
Response { seq: 0, type: 'response', request_seq: 8, command: 'disconnect', success: true }
zobo commented 8 months ago

Thanks. I'll try to reproduce it. Also. Do you have any other php related vscode extensions installed?

Theres also an "extension bisect" process I'll ask you to do, if I can't reproduce the problem.

Best!

andrew-laughlin commented 8 months ago

A little more about my setup. I'm working on a Wordpress plugin and using Local 8.2 (which includes Xdebug 3.3.0). For unit tests I've been using the Devsense PHP extension (v1.42.14626). I've disabled this extension for troubleshooting.

The only other installed extension are .NET related.

zobo commented 8 months ago

Devsense and this plugin are sadly incompatible and "strange things" happen. Does the error happen when Devsense is disabled?

andrew-laughlin commented 8 months ago

Yes, Devsense is disabled when the error occurs.

On Tue, Jan 9, 2024, 8:54 AM Damjan Cvetko @.***> wrote:

Devsense and this plugin are sadly incompatible and "strange things" happen. Does the error happen when Devsense is disabled?

— Reply to this email directly, view it on GitHub https://github.com/xdebug/vscode-php-debug/issues/949#issuecomment-1883423301, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE44M2MX4SC7WHAW6LPTPP3YNVY55AVCNFSM6AAAAABBSNW4RGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBTGQZDGMZQGE . You are receiving this because you authored the thread.Message ID: @.***>

zobo commented 8 months ago

I can confirm this does happen. I tried it on my windows PC and there it does not, then I tried Remote SSH to my debian VM and there I see it. When I stop the debugger, I get two of these exceptions.

The exception seems to happen on the fronted tho (see the paths)

image

In any case, debugging seems to work. I'll try to poke around this and report it to the vscode team...

Version: 1.85.1 (user setup) Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2 Date: 2023-12-13T09:49:37.021Z Electron: 25.9.7 ElectronBuildId: 25551756 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.22621

zobo commented 1 month ago

I'll close this, as VSCode team is still working on this, but does not seem to interfere much with the extension. A newer issue https://github.com/microsoft/vscode/issues/196948