Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VSCode] Debugger does not start in launch mode #14241

Open
elemental-mind opened this issue Sep 29, 2024 · 2 comments
Open

[VSCode] Debugger does not start in launch mode #14241

elemental-mind opened this issue Sep 29, 2024 · 2 comments
Labels
bug Something isn't working debugger Something to do with `bun --inspect` or the debugger

Comments

@elemental-mind
Copy link

What version of Bun is running?

1.1.30-canary.71+af82a446d, VSCode Extension Version v0.0.15

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What steps can reproduce the bug?

  1. Fresh VSCode project with a single code-file
  2. Add the default launch.json config that the debugger suggests by default for bun:
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "bun",
            "internalConsoleOptions": "neverOpen",
            "request": "launch",
            "name": "Debug File",
            "program": "${file}",
            "cwd": "${workspaceFolder}",
            "stopOnEntry": false,
            "watchMode": false
        },
        {
            "type": "bun",
            "internalConsoleOptions": "neverOpen",
            "request": "launch",
            "name": "Run File",
            "program": "${file}",
            "cwd": "${workspaceFolder}",
            "noDebug": true,
            "watchMode": false
        },
        {
            "type": "bun",
            "internalConsoleOptions": "neverOpen",
            "request": "attach",
            "name": "Attach Bun",
            "url": "ws://localhost:6499/",
            "stopOnEntry": false
        }
    ]
}
  1. Run the debugger with the "Debug File" configuration in any code file in the project.

What is the expected behavior?

The debugger launches bun and attaches to it and stops at the first breakpoint set.

What do you see instead?

On the debug console I see the following output:

Failed to start debugger.
Program could not be started.

image

Also, the extension host complains about an invalid debug adapter:

2024-09-29 19:16:10.456 [error] Error: Invalid debug adapter
at c.p (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2012:95)
at c.$acceptDAMessage (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:2011:16481)
at S (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1903:14635)
at S.Q (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1903:14401)
at S.M (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1903:13434)
at S.L (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1903:12269)
at u.value (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1903:10964)
at o.B (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:93:732)
at o.fire (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:93:949)
at s.fire (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:123:15085)
at K.onmessage (vscode-file://vscode-app/c:/Users/magnu/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1919:8198)

Additional information

No response

@elemental-mind elemental-mind added bug Something isn't working needs triage labels Sep 29, 2024
@elemental-mind
Copy link
Author

elemental-mind commented Sep 29, 2024

For anyone looking for a workaround to the problem use the following setup:

.vscode/launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch and attach",
            "type": "bun",
            "request": "attach",
            "url": "ws://127.0.0.1:5000/test",
            "preLaunchTask": "Bun: Start Debugger",
            "internalConsoleOptions": "openOnSessionStart"
        }
    ]
}

.vscode/tasks.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Bun: Start Debugger",
            "type": "shell",
            "command": "bun --inspect-brk=127.0.0.1:5000/test test.ts",
            "isBackground": true,
            "problemMatcher": [
                {
                    "pattern": [
                        {
                            "regexp": ".",
                            "file": 1,
                            "location": 2,
                            "message": 3
                        }
                    ],
                    "background": {
                        "activeOnStart": true,
                        "beginsPattern": "Listening:",
                        "endsPattern": "ws://127.0.0.1:5000/test"
                    }
                }
            ]
        }
    ]
}

@elemental-mind elemental-mind changed the title [VSCode] Debugger can not debug in launch mode [VSCode] Debugger does not start in launch mode Sep 29, 2024
@nektro nektro added debugger Something to do with `bun --inspect` or the debugger and removed needs triage labels Oct 10, 2024
@MindStudioOfficial
Copy link

Can confirm this issue for bun 1.1.33 with VSCode on Windows and extension version v0.0.15.

Workaround works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working debugger Something to do with `bun --inspect` or the debugger
Projects
None yet
Development

No branches or pull requests

3 participants