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

Bun vscode extension breaks "javascript debug terminal" for node #15223

Open
ulugbekna opened this issue Nov 18, 2024 · 2 comments
Open

Bun vscode extension breaks "javascript debug terminal" for node #15223

ulugbekna opened this issue Nov 18, 2024 · 2 comments
Labels
bug Something isn't working vscode Something to do with the VSCode extension

Comments

@ulugbekna
Copy link

What version of Bun is running?

1.1.18

What platform is your computer?

Darwin 24.1.0 arm64 arm

What steps can reproduce the bug?

  1. Have Bun vscode extension installed
  2. Open command palette (cmd+shift+p or F1) and invoke command "debug: javascript debug terminal"
  3. In the newly opened javascript debug terminal, run node and see how debugger cannot attach to the process

What is the expected behavior?

Javascript debug terminal can attach to a new node process

What do you see instead?

Javascript debug terminal cannot attach to a new node process

Additional information

This's the cause of the problem -

async function injectDebugTerminal(terminal: vscode.Terminal): Promise<void> {
if (!getConfig("debugTerminal.enabled")) return;
const { name, creationOptions } = terminal;
if (name !== "JavaScript Debug Terminal") {
return;
}
const { env } = creationOptions as vscode.TerminalOptions;
if (env["BUN_INSPECT"]) {
return;
}
const stopOnEntry = getConfig("debugTerminal.stopOnEntry") === true;
const query = stopOnEntry ? "break=1" : "wait=1";
const debugSession = new TerminalDebugSession();
await debugSession.initialize();
const { adapter, signal } = debugSession;
const debug = vscode.window.createTerminal({
...creationOptions,
name: "JavaScript Debug Terminal",
env: {
...env,
"BUN_INSPECT": `${adapter.url}?${query}`,
"BUN_INSPECT_NOTIFY": signal.url,
},
});
debug.show();
// If the terminal is disposed too early, it will show a
// "Terminal has already been disposed" error prompt in the UI.
// Until a proper fix is found, we can just wait a bit before
// disposing the terminal.
setTimeout(() => terminal.dispose(), 100);
}
.

@connor4312 (from the vscode team, who works on debugging experience) would be happy to add some simple metadata to JS debug terminal environment to make Bun debugging work well.

@ulugbekna ulugbekna added bug Something isn't working needs triage labels Nov 18, 2024
@connor4312
Copy link

This happens because js-debug creates a unix socket / named pipe server that will listen until the associated terminal is closed, and Bun closing the terminal make the server shut down.

@Electroid Electroid added vscode Something to do with the VSCode extension and removed needs triage labels Nov 18, 2024
@Electroid
Copy link
Contributor

We'd love so that both Node and Bun work in the JavaScript debugger, are there any suggestions from the VSCode team on the canonical way to make this work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vscode Something to do with the VSCode extension
Projects
None yet
Development

No branches or pull requests

3 participants