oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.49k stars 2.71k forks source link

vscode - extension breaks the javascript debug terminal #5208

Open DetachHead opened 1 year ago

DetachHead commented 1 year ago

What version of Bun is running?

1.0.1

What platform is your computer?

Darwin 22.1.0 x86_64 i386

What steps can reproduce the bug?

  1. install the oven.bun-vscode extension
  2. hover over an npm script in package.json and click "Debug Script" image

What is the expected behavior?

either:

What do you see instead?

"JavaScript Debug Terminal" appears and does nothing, and "Terminal has already been disposed" error displays on the bottom right

image

Additional information

No response

andrewbranch commented 12 months ago

Just discovered this with slightly different repro steps and symptoms. I usually use the JavaScript Debug Terminal by manually opening it from the Terminal panel:

context menu for add terminal

Running any Node.js process from this terminal is supposed to auto-attach the debugger. When the extension is installed, commands from this terminal execute normally, but the debugger never attaches. (Running bun from this terminal also does not initiate any debug functionality.)

pokey commented 10 months ago

Fwiw, in addition to the aforementioned issue, I find that nothing happens when I run the Bun: Run File (extension.bun.runFile) or Bun: Debug File (extension.bun.debugFile) commands to run the currently opened script. No error, just silently does nothing. I'm guessing these have the same root cause as this issue, as it appears from the code that they both factor through the same functions

Note that when I use the hover action, the JavaScript Debug Terminal does open, but nothing gets typed in there and nothing runs. If I then manually run the script by typing eg bun myScriptName into the JavaScript Debug Terminal, it runs and the debugger attaches properly, which did not occur before I installed the extension

blimmer commented 7 months ago

Just discovered this same issue and easily isolated it to the Bun VSCode plugin. To reproduce the issue:

  1. Download VSCode from https://code.visualstudio.com/download
  2. Set up "portable mode" to isolate the issue entirely. Setting up portable mode depends on your platform: https://code.visualstudio.com/docs/editor/portable
  3. Create a test javascript file:

    // test.js
    function main() {
        debugger;
    }
    
    main();
  4. Open a Javascript Debug Terminal and run node test.js. You'll see it hit the breakpoint.
  5. Install the Bun VSCode extension and re-run the previous steps. The breakpoint is not longer hit.

Bun VSCode JavaScript Debug Terminal Issue - Watch Video

zardoy commented 4 months ago

Those who have already read the Readme.md are aware, but you can disable JavaScript Debug Terminal integration and debug Bun from the launch.json config or the F5 menu instead:

{
  "bun.debugTerminal.enabled": false
}

Or you can toggle the setting with Toggle when you need to debug Bun (remember to create a new terminal after that).