Compare commits

...

1 Commits

Author SHA1 Message Date
Jarred Sumner
9412f889d7 Don't always wait for debugger 2024-11-23 21:47:50 -08:00
2 changed files with 17 additions and 3 deletions

View File

@@ -2015,7 +2015,7 @@ pub const VirtualMachine = struct {
this.debugger = Debugger{
.path_or_port = null,
.from_environment_variable = notify,
.wait_for_connection = true,
.wait_for_connection = wait_for_connection,
.set_breakpoint_on_first_line = set_breakpoint_on_first_line,
.mode = .connect,
};

View File

@@ -104,6 +104,7 @@ export default function (
isAutomatic: boolean,
urlIsServer: boolean,
): void {
$debug("Connect: " + url + (urlIsServer ? " (server)" : "") + (isAutomatic ? " (automatic)" : ""));
if (urlIsServer) {
connectToUnixServer(executionContextId, url, createBackend, send, close);
return;
@@ -145,7 +146,7 @@ export default function (
const path = require("node:path");
notify({
// This is actually a filesystem path, not a URL.
unix: path.resolve(notifyUrl.substring("unix://".length)),
unix: path.resolve(unescapeUnixSocketUrl(notifyUrl)),
});
} else {
const { hostname, port } = new URL(notifyUrl);
@@ -159,7 +160,16 @@ export default function (
function unescapeUnixSocketUrl(href: string) {
if (href.startsWith("unix://%2F")) {
return decodeURIComponent(href.substring("unix://".length));
return unescapeUnixSocketUrl(decodeURIComponent(href.substring("unix://".length)));
}
const questionMarkIndex = href.lastIndexOf("?");
if (questionMarkIndex !== -1) {
return unescapeUnixSocketUrl(href.substring(0, questionMarkIndex));
}
if (href.startsWith("unix://")) {
return href.substring("unix://".length);
}
return href;
@@ -279,6 +289,10 @@ class Debugger {
};
socket.ref();
},
connectError: (socket, error) => {
this.#createBackend(true, () => {}).close();
$debug("connectError:" + error);
},
data: (socket, bytes) => {
if (!socket.data) {
socket.terminate();