aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-debug-adapter-protocol/debugger
diff options
context:
space:
mode:
Diffstat (limited to 'packages/bun-debug-adapter-protocol/debugger')
-rw-r--r--packages/bun-debug-adapter-protocol/debugger/adapter.ts23
1 files changed, 16 insertions, 7 deletions
diff --git a/packages/bun-debug-adapter-protocol/debugger/adapter.ts b/packages/bun-debug-adapter-protocol/debugger/adapter.ts
index c86fb2d85..1dfdcf7bb 100644
--- a/packages/bun-debug-adapter-protocol/debugger/adapter.ts
+++ b/packages/bun-debug-adapter-protocol/debugger/adapter.ts
@@ -5,6 +5,7 @@ import type { ChildProcess } from "node:child_process";
import { spawn, spawnSync } from "node:child_process";
import capabilities from "./capabilities";
import { SourceMap } from "./sourcemap";
+import { compare, parse } from "semver";
type LaunchRequest = DAP.LaunchRequest & {
runtime?: string;
@@ -337,6 +338,21 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
return;
}
+ if (subprocess.exitCode === null && !subprocess.kill() && !subprocess.kill("SIGKILL")) {
+ this.#emit("output", {
+ category: "debug console",
+ output: `Failed to kill process ${subprocess.pid}\n`,
+ });
+ }
+
+ const { stdout: version } = spawnSync(runtime, ["--version"], { stdio: "pipe", encoding: "utf-8" });
+
+ if (parse(version, true) && compare("0.8.0", version, true)) {
+ throw new Error(
+ `Bun v${version.trim()} does not have debugger support. Please upgrade to v0.8 or later by running: \`bun upgrade\``,
+ );
+ }
+
for (const message of stderr) {
this.#emit("output", {
category: "stderr",
@@ -357,13 +373,6 @@ export class DebugAdapter implements IDebugAdapter, InspectorListener {
});
}
- if (subprocess.exitCode === null && !subprocess.kill() && !subprocess.kill("SIGKILL")) {
- this.#emit("output", {
- category: "debug console",
- output: `Failed to kill process ${subprocess.pid}\n`,
- });
- }
-
throw new Error("Program started, but the debugger could not be attached.");
}