-
Notifications
You must be signed in to change notification settings - Fork 7
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
Debugging functionality #250
Comments
Hi @nkskaare @FedeAbella Hope we can sort this out in collaboration ❤️! |
Happy to collaborate on this! What I've done so far is only a POC and I was able to run a debugging session in nvim. However, I'm quite new to nvim and not very skilled in lua, so that's why I thought it would be better handed over to someone who can implement this properly. The details for running the debug server could be found in launch.json of the vscode-extension repo I linked above {
"name": "Launch Replay Debugger adapter",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/packages/salesforcedx-apex-replay-debugger/out/src/adapter/apexReplayDebug.js",
"args": ["--server=4712"],
"sourceMaps": true,
"smartStep": true,
"outFiles": ["${workspaceFolder}/packages/*/out/src/**/*.js"],
"sourceMapPathOverrides": {
"webpack:///salesforcedx-utils-vscode/./*": "${workspaceFolder}/packages/salesforcedx-utils-vscode/*",
"webpack:///salesforcedx-sobjects-faux-generator/./*": "${workspaceFolder}/packages/salesforcedx-sobjects-faux-generator/*",
"webpack:///*": "*"
},
"preLaunchTask": "Compile"
}, The project needs to be compiled (typescript) and then run the |
Ooooh, I love this! Great work @nkskaare. I've had this going around my head for a while now and didn't know how to tackle it. To be honest, I haven't used
Let me see what I can put together from what nkskaare shared, when I've got some time, and we can make it from there. I could probably use your help with knowing more about this already @nkskaare, if I run into some blockers. |
Great! Let's keep this thread open. Feel free to @me if any help from me is needed. |
Great! I have used the debugger in VSCode quite actively, and spent some time trying to unwrap what happens under the hood when setting up this POC, so happy to share my insight. I agree very much with the things listed here. My current code is quite a naive approach, but it shows the core of it. The debugger requires some additional details on breakpoint lines from the language server, hence the One problem with my current config/code as you can probably figure is that it runs when the nvim-dap plugin is loaded (using lazy.nvim), so this code should probably be triggered by a command implemented in the sf plugin. With the current config I have to restart nvim each time I want to run a debugging session. I have also read somewhere that nvim-dap can read launch.json files, so this could also be a feature to explore further. As you suggest i think in a first iteration the user should setup the server on their own. As I was fiddling around with this I found out that it was quite simple to set up (compile project and run Furthermore some sf cli commands must be run to actually start logging debug logs and create DebugLevel and TraceFlag records in Salesforce. In VSCode these are triggered by running $ sf data:query --query SELECT id, logtype, startdate, expirationdate, debuglevelid, debuglevel.apexcode, debuglevel.visualforce FROM TraceFlag WHERE logtype='DEVELOPER_LOG' AND TracedEntityId='005KO000001AS22YAG' --use-tooling-api --json
$ sf data:create:record --sobject DebugLevel --values developername=ReplayDebuggerLevels1727860853933 MasterLabel=ReplayDebuggerLevels1727860853933 apexcode=FINEST visualforce=FINER --use-tooling-api --json
$ sf data:create:record --sobject TraceFlag --values tracedentityid='005KO000001AS22YAG' logtype=developer_log debuglevelid=7dlKO000000Cd6CYAS StartDate='' ExpirationDate='Wed, 02 Oct 2024 09:50:55 GMT --use-tooling-api --json TracedEntityId is the user id. By default this sets the expiration for the TraceFlag 30 minutes ahead in time (quite an annoyance sometimes, could be nice with a longer/custom expiration time) Getting the logs from salesforce can also be acheived with the cli sf apex get log I think it's a very good suggestion to have functionality to debug a chosen log. Two methods like |
Hey @nkskaare! Sorry, it's been a hectic week, I'm only just now able to start looking into this. Unfortunately, I don't know much node and TS, so I'm running into blockers early on with just trying to get the debugging server up and running. Could you help me out by providing some steps to compile the project and getting the server running? Thanks! |
Sure! Let me see what i can do! I'll try to make a small step-by-step guide. |
Sorry for the late response, hectic week on my side as well! First, clone the salesforce-vscode repo Ensure you have npm and typescript installed. Typescript can be installed using npm at the project root, run Then you should be able to run the adapter You should see the following message |
Sounds straightforward enough. Thanks! I'll let you know when I've made some progress on this. |
Hi!
I have been able to run the debugger from https://github.com/forcedotcom/salesforcedx-vscode as a server and connect to it using the nvim-dap. My implementation still has some work to do, but I am getting close, and it would be very cool to implement it into this plugin. My current nvim-dap configuration is the following. I am still struggling to dynamically pass in a logfile which i want to debug. Ideally I would like to run a test and then have a debug session it afterwards, not having to manually select which logfile i want to run (which is how it is implemented in vscode today).
The text was updated successfully, but these errors were encountered: