Skip to content

Unknown thread ID #931

@MitchTalmadge

Description

@MitchTalmadge

Recently I've been getting an Unknown thread ID error in my VSCode when hitting a breakpoint. It used to work, I don't know what changed.

PHP version: 7.4.16
Xdebug version: 3.1.5
VS Code extension version: 1.33.1

Your launch.json:
Xdebug php.ini config:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "xdebug",
      "type": "php",
      "request": "launch",
      "port": 9003,
      "pathMappings": {
        "/app": "${workspaceRoot}"
      },
      "xdebugSettings": {
        "max_data": 5000,
        "max_children": 300
      }
    },
  ]
}

Xdebug logfile (from setting xdebug.log in php.ini):

[8618] Log opened at 2023-11-02 00:13:05.355306
[8618] [Step Debug] INFO: Connecting to configured address/port: 10.4.0.1:9003.
[8618] [Step Debug] INFO: Connected to debugging client: 10.4.0.1:9003 (through xdebug.client_host/xdebug.client_port). :-)
[8618] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///app/public/index.php" language="PHP" xdebug:language_version="7.4.16" protocol_version="1.0" appid="8618"><engine version="3.1.5"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init>

[8618] [Step Debug] <- feature_set -i 1 -n resolved_breakpoints -v 1
[8618] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="resolved_breakpoints" success="1"></response>

[8618] [Step Debug] <- feature_set -i 2 -n notify_ok -v 1
[8618] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="notify_ok" success="1"></response>

[8618] [Step Debug] <- feature_set -i 3 -n extended_properties -v 1
[8618] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="3" feature="extended_properties" success="1"></response>

[8618] [Step Debug] <- feature_get -i 4 -n breakpoint_include_return_value
[8618] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_get" transaction_id="4" feature_name="breakpoint_include_return_value" supported="0"><![CDATA[0]]></response>

[8618] [Step Debug] <- feature_set -i 5 -n max_data -v 5000
[8618] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="5" feature="max_data" success="1"></response>

[8618] [Step Debug] <- feature_set -i 6 -n max_children -v 300
[8618] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="6" feature="max_children" success="1"></response>

[8618] [Step Debug] <- run -i 7
[8618] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="7" status="stopping" reason="ok"></response>

[8618] [Step Debug] <- stop -i 8
[8618] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="8" status="stopped" reason="ok"></response>

[8618] Log closed at 2023-11-02 00:13:05.517521

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

Not sure how much to include but I think this covers it:

-> threadsRequest
{ command: 'threads', type: 'request', seq: 13 }

<- threadsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 13,
  command: 'threads',
  success: true,
  body: { threads: [ Thread { id: 6, name: 'Request 6 (1:25:02 AM)' } ] } }

-> stackTraceRequest
{ command: 'stackTrace',
  arguments: { threadId: 6, startFrame: 0, levels: 20 },
  type: 'request',
  seq: 14 }

xd(6) <- stack_get -i 9
<- outputEvent
OutputEvent {
  seq: 0,
  type: 'event',
  event: 'output',
  body: { category: 'console', output: 'connection 6 closed\n' } }

connection 6 closed
<- continuedEvent
ContinuedEvent {
  seq: 0,
  type: 'event',
  event: 'continued',
  body: { threadId: 6, allThreadsContinued: false } }

<- threadEvent
ThreadEvent { seq: 0, type: 'event', event: 'thread', body: { reason: 'exited', threadId: 6 } }

-> stackTraceRequest
{ command: 'stackTrace',
  arguments: { threadId: 6, startFrame: 0, levels: 20 },
  type: 'request',
  seq: 15 }

<- stackTraceResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 15,
  command: 'stackTrace',
  success: false,
  message: 'Unknown thread ID',
  body: { error: { id: 0, format: 'Unknown thread ID', showUser: true } } }

Code snippet to reproduce:
N/A, happens anywhere.

Seems to be related to this line:

if (!connection) {
throw new Error('Unknown thread ID')
}

I noticed that my connection was closed after hitting the breakpoint. I wonder if that is the cause, and how I might fix it.

I'm going to be researching a fix for this on my own, but I wanted to post the problem here to document my findings.

P.S. Thank you for your work on this plugin, it's very valuable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions