vscode-js-debug
vscode-js-debug copied to clipboard
Support for `workerd` (Cloudflare Workers)
Similarly to this Deno issue, we'd love to be able to natively support auto-attaching to workerd processes when running in a JS debug terminal.
Unfortunately (like Deno), workerd doesn't read the NODE_OPTIONS env var, and doesn't (and won't) support require hooks of the form needed to load the bootloader script. It'd be great to figure out what the right integration pattern here is—whether it's us reading VSCODE_INSPECTOR_OPTIONS directly, or us somehow running a subset of the bootloader script.
As a first pass, I had a go at seeing what us running the watchdog script directly would look like, and it seems to work fairly well: https://github.com/cloudflare/workers-sdk/pull/9535/files#diff-43ebb33e60024410f187f4099d80c0e0ebfe53b837a046643fdf055aba8cc613R183-R220. I'm a tad worried about how many assumptions about the internals of vscode-js-debug that requires though—is the watchdog interface likely to remain stable?
is the watchdog interface likely to remain stable?
Maybe, we make no promises.
I notice there is a Cloudflare workers extension already https://marketplace.visualstudio.com/items?itemName=cloudflare.cloudflare-workers-bindings-extension. Could you leverage the API I made for Deno/Bun to add your own hooks to the debug terminal? https://github.com/microsoft/vscode-js-debug/blob/main/EXTENSION_AUTHORS.md#extension-api
@connor4312 I think ideally we'd love for this to work without users having to install an extension, especially because right now our extension doesn't do anything special debugging-wise (and judging by the Bun code that uses that API there's a requirement to start a debug session manually in the extension/implement a debugger extension?). I might be misunderstanding how this is meant to be used though.
there's a requirement to start a debug session manually in the extension
Yes, but this is pretty easy via a call to `vscode.debug.startDebugging
I think ideally we'd love for this to work without users having to install an extension
Yea, that part is a little trickier in your case.
While it's not stable public API, what you have there is probably fine. I've not changed that interface in the last fews years and don't plan to change it in the forseeable future.