-
Notifications
You must be signed in to change notification settings - Fork 139
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
Debug support #12
Comments
wip |
Hi, I work on the VS Code javascript debug extension. Since you're based on V8 and CDP, and there are reports of attach configs just working, it may sense to plug into our existing Javascript debugger. (Note that we're working on releasing a new debugger; I'd recommend targeting that as the standard.) More than happy to provide pointers / brainstorm, Let me know how I can help 🙂 |
Docs for VSCode debugging: https://deno.land/manual/tools/debugger#vscode |
thanks |
I had problems displaying to the standard output with the default configuration,
Not sure if this is a known bug @bartlomieju |
I followed the guideline using the following launch.json
Which starts the debugger session and then immediately quits...
Any ideas? |
@cvlvxi Maybe your |
@pirix-gh If you don't like that the debug output occupies a terminal window, you can also add |
@gewoonwoutje this does not work for me, unfortunately. Not sure why, but I always had the same problem with Node.js. Could be from my environment (ubuntu). |
@gewoonwoutje thanks from the response. How can I make it so that my ts file has a process that keeps running? |
@cvlvxi just see deno offical document like run a http server import { serve } from "https://deno.land/std/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
req.respond({ body: "Hello World\n" });
} |
I've following the comments here as well as on https://deno.land/manual/tools/debugger#vscode but my breakpoints are always unbounded and they will never be able to be hit when the program executes. I'm on Windows 10 using VSCode Insiders. I've even tried using the sample program and setting the breakpoint on the console.log message but it's still unbound. I'm using Deno 1.1.3. Anyone else having issues like this? |
@frankhale can you try with our new debugger? (This debugger will become the default in the VS Code release upcoming this week.) If that doesn't work, please file an issue! |
I think I know what's going on in my case. For the record I'm on Windows 10 and have tried VSCode (regular release) and Visual Studio Insiders (latest build from today, using nightly version of the JavaScript Debugger). It really looks like --inspect-brk is being completely ignored when using the following launch.json. When pressing F5 the app will launch but the debugger is never started and consequently cannot attach.
If I run my app from the terminal using:
|
@connor4312 I am using the brand new I am running Centos 8.2 Linux. |
@David-Else correct I see those same results but I'd like to mention that when it says "Unable to retrieve source content." you can click the debugger continue button and it will resume execution of your app and if you have breakpoints you should be able to hit them. This is the work around I'm using currently. I'd also like to thank you for providing another example of the behavior. I am thinking that the bug is happening with the launch.json profile for launching deno and attaching with just an F5 press and I think it has something to do with the runtimeArgs property |
@frankhale Cheers! Also, it won't work with |
It's related to how the new debugger works -- it actually includes a "bootloader" file to set up debugging. This has many advantages, but is incompatible with --inspect-brk: that would cause Node to break in our bootloader, at which point VS Code will not have been told that there's something to debug! If the new debugger sees --inspect-brk, it filters it out and instead manually sets a breakpoint on the first line of user code that would be run. Deno somewhat predictably (but I wanted to check) doesn't read from the NODE_OPTIONS environment variable that we leverage to inject the bootloader, so something else will need to be done there. I will introduce some compatibility logic into js-debug within the coming days. |
@connor4312 I have deleted the line and now and it still does not work. Can this config be made compatible?
|
Given you're on 1.47 where the new debugger is now the default, you have a couple options until this capability is unlocked in js-debug:
|
@connor4312 Thanks for the additional help, but I get the following error with your task:
Deno runs OK:
And here is the exact code I copied from yours, just changing the file name and adding {
"version": "2.0.0",
"tasks": [
{
"label": "run my program",
"type": "shell",
"command": "deno run --inspect-brk -A mod.ts", // your program args
"isBackground": true, // don't wait for the task to end before debugging
"problemMatcher": {
// tells vscode to wait for this line before debugging
"background": {
"activeOnStart": true,
"beginsPattern": "Debugger listening"
}
}
}
]
} |
@David-Else did you try just the first option? That worked for me
|
@brandonkal It works!!! Finally after all this time I can now debug deno, thanks! (note: just use official settings https://deno.land/manual/tools/debugger#vscode and the old debugger in VS Code 1.47) |
In js-debug, process attachment in general (for Node.js) is done by injecting a "bootloader" script in the NODE_OPTIONS environment variable. This lets us do plenty of really cool things, like automatically attaching to child process and building the Debug Terminal. However, the bootloader doesn't work for all scenarios, namely: 1. Deno does not support NODE_OPTIONS 2. Some people `docker run` from their launch configuration, through which the bootloader isn't and can't be propagated. So this brings back the 'old fashioned' attach mode for these scenarios. The parameter is renamed `attachSimplePort` from simply `port`, because the have lots of existing users with `port` in their options for whom the bootloader will work perfectly and unlock additional functionality. If attachSimplePort is given, we won't inject the bootloader at all, so child processes won't be debugged automatically, but it should work. Fixes: #586 Fixes discussion in: denoland/vscode_deno#12
Hi all, I've added 'official' support for this in js-debug now. See microsoft/vscode-js-debug@540fbca for details and reasoning, the tl;dr is that (if you'd like to continue using the new debugger, which I'd encourage 🙂 ) you need to do two things:
Then it should work. This change will land in the next VS Code stable release, at which point you will no longer need to be on the nightly extension build. I will PR to the deno docs to update this) |
POST: |
I'm having a problem stepping into library code e.g. Oak next function vscode tells me "Unable to retrieve source contents" also I'm seeing a problem going to source code definitions. vscode displays the IntelliSense but when I select got definition vscode reports it can't find the definition of function (e.g. validateJwt). I'm using deno 1.2.0. Library is imported in a deps.ts file: export { makeJwt } from "https://deno.land/x/djwt@v1.2/create.ts"; export { Then included into the code using import { Status, validateJwt } from "../deps.ts"; Any suggestions as to what the issue is or best way to debug. see: https://discordapp.com/channels/684898665143206084/689420767620104201/739903606978904196 |
@connor4312
and then got error:
But if I change |
I successfully used code-insiders to debug Deno. It probably should also work with the just released 1.48. I use a config like this: { { |
Whenever I debug a project now, a file
I can close that file and resume debugging, though it gets cumbersome. The
Also tried
Does anybody experience similar issues? What could be the cause? (VS Code 1.48, vs-deno 2.0.15) |
I got this up and running witout big issues, but pretty new to vscode debugger, so my question might be dumb =): Is it somehow possible to interact with the running code trough the debugger? E.g. is it somehow possible to inspect a variable at runtime with |
@kryptish you might like logpoints https://code.visualstudio.com/docs/editor/debugging#_logpoints |
If I change
|
It means your program is not listening on that port, or if it is we couldn't connect to it. |
So the conclusion is if change |
How to set ENV="development" for debugging? |
@YuriyTigiev There are |
@bela53 I am experiencing a very similar message:
☝️ This is always a reference to a remote module. And I get a VS Code notification in the bottom right that reads:
with the options
It seems that I can just click the Continue button (looks like a play button or triangle) and the debug will continue to my first breakpoint successfully. If it's helpful, this is my {
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Deno",
"request": "launch",
"type": "pwa-node",
"program": "${file}",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": [
"run",
"--inspect-brk",
"--allow-all"
],
"attachSimplePort": 9229
}
]
} I'm not sure what is causing this problem. @bartlomieju Do you have any insight? |
I just set up debugging with deno in VS Code and in general it works well but when I want it to output everything to the console I always get an error message "The terminal process terminated with exit code: 1". At first glance the issue seems to be that deno is exiting too quickly. If I try it with node it outputs "Waiting for the debugger to disconnect..." after the program terminated and only exits when I end the debugging but deno closes immediately. When I then press terminate in the debugging interface I get the aforementioned error. Here's the configuration I am using: {
"name": "Deno: Debug",
"request": "launch",
"type": "pwa-node",
"program": "${file}",
"cwd": "${fileDirname}",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "--unstable", "--inspect-brk", "--allow-all"],
"console": "integratedTerminal" // <--- This is the problematic line
} |
It looks like a debugger regression was introduced in v1.6.2. I can debug from VS Code fine with v1.6.1 and earlier using a configuration like this:
However, upgrading to v1.6.2 results in this error when trying to connect the debugger:
A temporary fix is to just roll back to the last working version:
|
@drcallaway Could you open an issue on the denoland/deno repo? |
This is a long thread that is unactionable as it stands at the moment. Closing. If anyone has specific issues with debug or debug support, best to open a new issue. |
@kitsonk I have seen other posts closed with this kind of sentiment. Perhaps it would help to provide actionable criteria in new issue templates so that everyone affected and participating can subscribe to issues with confidence that they'll not be closed without resolution. |
@jsejcksn can you please indicate what is not resolved with this issue? The issues states:
That feature is/has been available for a long time. Is that not working for you? |
@kitsonk Certainly; no problem. It is still not working for me. I am still experiencing the same result as in my previous comment: #12 (comment) Here is some additional information: When I have no If I then create a custom launch config file, I can get further in the debug process, but only to the point described in my previous comment. For comparison, here are multiple debug configs, commented to explain their sources: {
"version": "0.2.0",
"configurations": [
{
"name": "Deno (from extension)", // generated by using "Add configuration... > Deno: Run"
"type": "pwa-node",
"request": "launch",
"program": "${workspaceFolder}/main.ts", // it seems "main.ts" is assumed, but the file might not exist
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": [
"run",
"--inspect=127.0.0.1:9229",
"--allow-all" // unsafe default
],
"attachSimplePort": 9229
},
{
"name": "Deno (from manual)", // from https://deno.land/manual@v1.8.3/getting_started/debugging_your_code#vscode
"type": "pwa-node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "--inspect-brk", "-A", "${file}"], // unsafe default permissions
"attachSimplePort": 9229
},
{
"name": "Deno (custom)", // manually created
"type": "pwa-node",
"request": "launch",
"program": "${file}",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "deno",
"runtimeArgs": [
"run",
"--inspect-brk"
],
"attachSimplePort": 9229
}
]
} I ran this test again today on WSL, but haven't tested again on macOS yet. Here is a zip file containing the workspace folder used when I did this test before posting this comment: Env:
|
When an issue, which asked for a feature to be implemented, is implemented, the issue should have been closed at that point. It wasn't. This issue has around 30 comments, all over the place, for specific and non-specific problems. That is what makes an issue unactionable. I have moved your example to a specific new issue. |
Any cleanup of this issue's thread ought to update Deno Manual's documentation of Tools > Debugger > VSCode, which points to this issue as covering current status of the VSCode plugin. Might be a good idea to update the Limitations section and link it to any major individual issues if this current monolithic, catch-all issue is dead. |
I noticed if I hit F5 to run & debug it doesn't work. What's the status and upstream work to be done for this feature?
The text was updated successfully, but these errors were encountered: