-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix for windows debug support #14048
Changes from 3 commits
49090cf
773a3ee
bc66697
aea25a4
e291637
5e6b000
3d45d68
802b408
13518c4
5d0275e
6a0ad7f
32c5479
693dea4
2626b89
f83db90
e8b2fb5
27f7965
8beb0d3
ba54a17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
// @bun | ||
console.log("HELLO"); | ||
console.log(process.argv0); | ||
console.log("HELLO 2"); | ||
console.log("HELLO 3"); | ||
a(); | ||
|
||
function a() { | ||
console.log("HELLO 4"); | ||
} | ||
|
||
let i = 0; | ||
while (true) { | ||
console.log(i); | ||
i++; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ buildSync({ | |
entryPoints: ["src/extension.ts", "src/web-extension.ts"], | ||
outdir: "dist", | ||
bundle: true, | ||
external: ["vscode"], | ||
external: ["vscode", "ws"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this intentional? |
||
platform: "node", | ||
format: "cjs", | ||
// The following settings are required to allow for extension debugging | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,11 +28,21 @@ export default function ( | |
Bun.write(Bun.stderr, dim("--------------------- Bun Inspector ---------------------") + reset() + "\n"); | ||
} | ||
|
||
const unix = process.env["BUN_INSPECT_NOTIFY"]; | ||
if (unix) { | ||
const { protocol, pathname } = parseUrl(unix); | ||
if (protocol === "unix:") { | ||
notify(pathname); | ||
if (process.platform === "win32") { | ||
const notifyUrl = process.env["BUN_INSPECT_NOTIFY"]; | ||
if (notifyUrl) { | ||
const { protocol } = new URL(notifyUrl); | ||
if (protocol === "ws:" || protocol === "wss:") { | ||
notifyWebSocket(notifyUrl); | ||
} | ||
} | ||
} else { | ||
const unix = process.env["BUN_INSPECT_NOTIFY"]; | ||
if (unix) { | ||
const { protocol, pathname } = parseUrl(unix); | ||
if (protocol === "unix:") { | ||
notify(pathname); | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -73,7 +83,7 @@ class Debugger { | |
#listen(): void { | ||
const { protocol, hostname, port, pathname } = this.#url; | ||
|
||
if (protocol === "ws:" || protocol === "ws+tcp:") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're allowing wss, where is the TLS configuration specified? |
||
if (protocol === "ws:" || protocol === "wss:" || protocol === "ws+tcp:") { | ||
const server = Bun.serve({ | ||
hostname, | ||
port, | ||
|
@@ -94,7 +104,7 @@ class Debugger { | |
return; | ||
} | ||
|
||
throw new TypeError(`Unsupported protocol: '${protocol}' (expected 'ws:', 'ws+unix:', or 'unix:')`); | ||
throw new TypeError(`Unsupported protocol: '${protocol}' (expected 'ws:', 'ws+unix:', or 'wss:')`); | ||
} | ||
|
||
get #websocket(): WebSocketHandler<Connection> { | ||
|
@@ -321,6 +331,18 @@ function reset(): string { | |
return ""; | ||
} | ||
|
||
function notifyWebSocket(url: string): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, it's a whole websocket server for this? We can just make a TCP connection. |
||
const ws = new WebSocket(url); | ||
ws.onopen = () => { | ||
ws.send("1"); | ||
ws.close(); | ||
}; | ||
ws.onerror = error => { | ||
// Handle error if needed | ||
console.error("WebSocket error:", error); | ||
}; | ||
} | ||
|
||
function notify(unix: string): void { | ||
Bun.connect({ | ||
unix, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to wait for the callback to be called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it works fine without waiting for callback
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does node gurantee that the address will always be set before the listen callback is invoked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.