vscode-php-debug icon indicating copy to clipboard operation
vscode-php-debug copied to clipboard

"Unknown sourceReference 0" on debug initialization error

Open Unradelic opened this issue 7 months ago • 18 comments

Edit: This issue is very likely tied to an ongoing issue with VSCode and the way it initializes a debugger instance when it's tied to communicating with a debug extensions, like Xdebug.

Original issue message:

I don't know how or why, but the last PR to main (https://github.com/xdebug/vscode-php-debug/pull/876) broke the extension for Linux upon debug session start. The error Exception has occurred: Error: Unknown sourceReference 0 keeps appearing in my Linux machines with PoP_OS and CachyOS. This issue doesn't happen in WSL2 (because, I presume it uses Ubuntu 22)

image

I have tested debugging the extension and checking out to the previous commit (c954087) and this problem doesn't appear anymore.

Out of curiosity, what is and what does OVSX_PAT? Why was this ENV removed?

Unradelic avatar May 18 '25 16:05 Unradelic

Hi @Unradelic. OVSX_PAT and VSCE_PAT are Open VSX and Visual Studio Code Extension Personal Access Tokens that are used to automatically publish this extension to both marketplaces. I removed OVSX_PAT because I needed to push out a fix and Eclipse Foundation that hosts OpenVSX.org was down for a long time. So this has nothing to do with the extensions functionality.

In the referenced commit however, I did some manipulation of "Evaluate Request" handling that is linked to how VSC handles the watch window.

Regarding your error. Please provide the full log from DEBUG CONSOLE, so I can try to reproduce the issue. Please also provide the configuration from launch.json that you are using. sourceRequest is called by the IDE when it wants to get the contents of a virtual file.

zobo avatar May 18 '25 17:05 zobo

Important update: It looks like some inicialization problem, not at all regarding a random ENV being removed. I tried installing other versions directly from VSCode Marketplace and the same problem occurs. Then, I updated to the latest version within VSCode, reloaded extensions and now it works.

Then, if I close VSCode, reopen and run (no changes at all anywhere) I then get this... Image

And finally, if I run Developer: Restart Extension Host (without closing VSCode) then it works!

Unradelic avatar May 18 '25 17:05 Unradelic

Regarding of the DEBUG CONSOLE output, when this error ocurrs there is NO output there, like at all.

With all this, I assume it's a VSCode issue and not the extension. For the time being, I now know that it's an initialization error down the line between the extension host and extensions communication, so a workaround is, if this happens I just have to Developer: Restart Extension Host

Unradelic avatar May 18 '25 17:05 Unradelic

What about this in your screenshot?

Image

log:true needs to be set in launch.json.

If you can give me the whole output?

zobo avatar May 18 '25 18:05 zobo

Sorry, Im an idiot, forgot to set "log":true... 😅

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/var/www/html": "${workspaceFolder}/remote",
            },
            "log":true,
        },
    ]
}

Image

<- launchResponse
Response { seq: 0, type: 'response', request_seq: 2, command: 'launch', success: true }
<- initializedEvent
InitializedEvent { seq: 0, type: 'event', event: 'initialized' }
-> setFunctionBreakpointsRequest
{ command: 'setFunctionBreakpoints',
  arguments: { breakpoints: [] },
  type: 'request',
  seq: 3 }
<- setFunctionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 3,
  command: 'setFunctionBreakpoints',
  success: true,
  body: { breakpoints: [] } }
-> setExceptionBreakpointsRequest
{ command: 'setExceptionBreakpoints',
  arguments: { filters: [ 'Notice', 'Warning', 'Error', 'Exception', '*' ] },
  type: 'request',
  seq: 4 }
<- setExceptionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 4,
  command: 'setExceptionBreakpoints',
  success: true,
  body:
   { breakpoints:
      [ { verified: true, id: 1 },
        { verified: true, id: 2 },
        { verified: true, id: 3 },
        { verified: true, id: 4 },
        { verified: true, id: 5 } ] } }
-> sourceRequest
{ command: 'source',
  arguments: { sourceReference: 0, source: { path: 'replinput' } },
  type: 'request',
  seq: 5 }
<- sourceResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 5,
  command: 'source',
  success: false,
  message: 'Unknown sourceReference 0',
  body: { error: { id: 0, format: 'Unknown sourceReference 0', showUser: true } } }
-> 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: [] } }

Unradelic avatar May 18 '25 18:05 Unradelic

I have not yet seen this replinput. Can you paste the exact vscode version from the help about menu?

zobo avatar May 18 '25 18:05 zobo

Of course, and thank you for your replies btw:

Version: 1.100.2
Commit: 848b80aeb52026648a8ff9f7c45a9b0a80641e2e
Date: 2025-05-14T21:47:40.416Z
Electron: 34.5.1
ElectronBuildId: 11369351
Chromium: 132.0.6834.210
Node.js: 20.19.0
V8: 13.2.152.41-electron.0
OS: Linux x64 6.12.10-76061203-generic

I was writing another reply (sorry for so many replies xD) but I get inconsistent behaviours... For days, every time I got this error upon launching VSCode debugger I just kept working with the debugger still running just in case at some point it suddenly starts working, but no chance. But now, I got the error, left the debugger active, made a request and hit a breakpoint... Im puzzled. I wish to know if it's me D:

Unradelic avatar May 18 '25 18:05 Unradelic

Sorry about the never ending questions. Can you also list all installed extensions? I think one way to get them is with code --list-extensions

zobo avatar May 18 '25 20:05 zobo

No problem at all! And that actually is a very good inquiry. Here's a list of the output for --list-extensions: I should probably tidy up and wipe many of them. I am going to do that now.

Enabled

a2k.hlsl-preview
atlassian.atlascode
bierner.docs-view
bmewburn.vscode-intelephense-client
eamodio.gitlens
editorconfig.editorconfig
eriklynd.json-tools
esbenp.prettier-vscode
github.codespaces
github.copilot
github.copilot-chat
golang.go
mblode.twig-language-2
mongodb.mongodb-vscode
ms-dotnettools.csdevkit
ms-dotnettools.csharp
ms-dotnettools.vscode-dotnet-runtime
ms-python.debugpy
ms-python.python
ms-python.vscode-pylance
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-wsl
ms-vscode.cmake-tools
ms-vscode.hexeditor
ms-vscode.remote-explorer
ms-vsliveshare.vsliveshare
natizyskunk.sftp
neilbrayfield.php-docblocker
njqdev.vscode-python-typehint
orsenkucher.vscode-graphql
redhat.vscode-xml
redhat.vscode-yaml
s-nlf-fh.glassit
shopify.theme-check-vscode
tomoki1207.pdf
unoplatform.vscode
will-stone.plastic
william-voyek.vscode-nginx
wraith13.unsaved-files-vscode
xdebug.php-debug
zokugun.explicit-folding

Disabled:

zehfernando.theme-actual-obsidian
mrmlnc.vscode-apache
alefragnani.bookmarks
ms-vscode.cpptools
ms-vscode.cpptools-extension-pack
ms-vscode.cpptools-themes
vadimcn.vscode-lldb
wallabyjs.console-ninja
pgourlain.erlang
zardoy.fix-all-json
ms-python.flake8
geequlim.godot-tools
mquandalle.graphql
george-alisson.html-preview-vscode
ms-vscode.js-debug-nightly
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-toolsai.vscode-jupyter-cell-tags
ms-toolsai.vscode-jupyter-slideshow
vscodevim.vim
ms-vscode.makefile-tools
rust-lang.rust-analyzer
gruntfuggly.todo-tree
tonybaloney.vscode-pets

Unradelic avatar May 18 '25 21:05 Unradelic

Thanks, but I was not yet able to reproduce the issue. I'm intrigued by this replinput word. There is no reference to it in php-debug extension nor in the vscode source (this exact format). So it could be it is somehow coming from some other extension. I'll try to search around to see if I can find a reference to it, but if you have the time and energy you can do a bisect extension search to figure out which extension is the bad one. Not sure how you can force vscode bisect to always load php-debug.

There is also a very simple first step. Since I saw you compiled php-debug from source, you can add "--disable-extensions" parameter to Launch Extension args and this will load no extensions - except the one you are developing (php-debug).

If you cannot reproduce the problem, then the fault is in some other extension.

zobo avatar May 19 '25 07:05 zobo

@zobo, did you find out anything about replinput btw.? I also got a report for my own debugger where a replinput source was requested and now I am curious what it does. The only mention of it I could find was in the elixir debugger, where there's a comment saying it's just "a special path that VSCode uses for debugger console"

Papierkorb2292 avatar Jul 30 '25 19:07 Papierkorb2292

Hi! Sadly no. I've still never seen this problem in my day-to-day usage. Are you seeing it? If yes, can you also lost the extensions you have installed. The comment from Elixir debugger extension is interesting, I'll look into it. Can you also give a link to your specific issue? Somebody also reported this to Xdebug directly https://bugs.xdebug.org/view.php?id=2302

zobo avatar Jul 31 '25 09:07 zobo

Unfortunately, I didn't have any success reproducing this either. I can't link to my issue because it was reported through Discord, but I'll see if they want to post the info here as well.

Papierkorb2292 avatar Jul 31 '25 19:07 Papierkorb2292

@zobo Hey, I'll get the issue on @Papierkorb2292's extension. These are all my extensions I currently have installed:

aaron-bond.better-comments
alexcvzz.vscode-sqlite
appliedengdesign.vscode-gcode-syntax
blitzz.twitch-chat
blockceptionltd.blockceptionvscodeminecraftbedrockdevelopmentextension
brapifra.phpserver
clarkio.twitch-highlighter
codeium.codeium
cweijan.dbclient-jdbc
cweijan.vscode-mysql-client2
destruc7i0n.vscode-bedrock-definitions
docker.docker
eamodio.gitlens
ecmel.vscode-html-css
editorconfig.editorconfig
esbenp.prettier-vscode
evermc.betonquest
firefox-devtools.vscode-firefox-debug
geequlim.godot-tools
github.vscode-github-actions
github.vscode-pull-request-github
golang.go
grepper.grepper
gruntfuggly.todo-tree
icrawl.discord-vscode
jannisx11.batch-rename-extension
jinliming2.vscode-go-template
mcbeet.vscode-beet
mechatroner.rainbow-csv
minecraftcommands.syntax-mcfunction
misodee.vscode-nbt
misodee.vscode-nbtdoc
ms-azuretools.vscode-containers
ms-azuretools.vscode-docker
ms-ceintl.vscode-language-pack-de
ms-dotnettools.csdevkit
ms-dotnettools.csharp
ms-dotnettools.vscode-dotnet-runtime
ms-kubernetes-tools.vscode-kubernetes-tools
ms-python.debugpy
ms-python.isort
ms-python.python
ms-python.vscode-pylance
ms-python.vscode-python-envs
ms-toolsai.jupyter
ms-toolsai.jupyter-keymap
ms-toolsai.jupyter-renderers
ms-toolsai.vscode-jupyter-cell-tags
ms-toolsai.vscode-jupyter-slideshow
ms-vscode-remote.remote-containers
ms-vscode-remote.remote-ssh
ms-vscode-remote.remote-ssh-edit
ms-vscode-remote.remote-wsl
ms-vscode.atom-keybindings
ms-vscode.cmake-tools
ms-vscode.cpptools
ms-vscode.cpptools-extension-pack
ms-vscode.cpptools-themes
ms-vscode.hexeditor
ms-vscode.makefile-tools
ms-vscode.remote-explorer
ms-vscode.vscode-serial-monitor
ms-vsliveshare.vsliveshare
myriad-dreamin.tinymist
natizyskunk.sftp
nobuwu.mc-color
oran9eutan.mcmodel-viewer
papierkorb2292.commandcrafter
postman.postman-for-vscode
qiaojie.binary-viewer
rangav.vscode-thunder-client
redhat.java
redhat.vscode-yaml
rioj7.commandonallfiles
ritwickdey.liveserver
shd101wyy.markdown-preview-enhanced
spgoding.datapack-language-server
stone926.minecraft-resourcepack-helper
streetsidesoftware.code-spell-checker
streetsidesoftware.code-spell-checker-german
stxr.iconfont-preview
superant.mc-dp-icons
tabnine.tabnine-vscode
tobylai.vscodeblocklypython
tomoki1207.pdf
visualstudioexptteam.intellicode-api-usage-examples
visualstudioexptteam.vscodeintellicode
vscjava.vscode-gradle
vscjava.vscode-java-debug
vscjava.vscode-java-dependency
vscjava.vscode-java-pack
vscjava.vscode-java-test
vscjava.vscode-maven
wakatime.vscode-wakatime
xdebug.php-debug
xdebug.php-pack
yzhang.markdown-all-in-one
zobo.php-intellisense

Kesuaheli avatar Jul 31 '25 19:07 Kesuaheli

Thanks a lot. Many extensions :) Are you able to also record a log of the DAP messages between vscode and the extension?

zobo avatar Jul 31 '25 19:07 zobo

Here's the log, but there doesn't seem to be anything interesting about it: dap_log.txt

We've also tested that this doesn't happen when all other extensions are disabled, however, running an extension bisect does not find any extension causing the issue, it actually says this might be a problem with VSCode. I might install all the extensions in the future to see if I can reproduce it that way.

Papierkorb2292 avatar Aug 09 '25 04:08 Papierkorb2292

I'm seeing this happen consistently, can this be related in any way to paths mapping? My project runs under docker. And I map project paths to container paths.

furai avatar Nov 18 '25 09:11 furai

Could you provide one full log and the list of extensions like above. Thanks

zobo avatar Nov 18 '25 10:11 zobo