question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Discussion: VSCode Debug Experience Improvement

See original GitHub issue

The “wait-debugger” method seems fraught with issues and slows down the write/test loop, for instance if I place one and forget to take it out, suddenly my code will “freeze” in production (assuming it misses a code review or I’m just testing).

Due to BreakAll, I understand the need for it, but perhaps when the function host is running in “vscode debug mode”, an environment variable can be set to show this, so that the wait-debugger can be conditional? E.G.:

if ($AZFUNC_IS_POSHDEBUG) {wait-debugger}

Method 1: Launch Configuration modify local.settings.json

Unfortunately launch configurations still don’t support postLaunchTask, otherwise my workaround for this would be:

  • prelaunch task to backup local.settings.json and then modify it to add the environment variable
  • postlaunch task to restore the original local.settings.json

This is not a great method because something going wrong can potentially leave the debug local.settings.json in place, but there aren’t any other obvious “hooks” into the azure function host that can be defined at runtime that safely remove the item. However since local.settings.json doesn’t get published or saved in git by default with the azure functions templates, it’s a “safe” item to work with that won’t affect a production deployment.

Method 2: Language Worker Parameter

Could maybe a language worker parameter be added that would add the environment variable natively and add that to the task? For instance the launch task would be:

func host start --language-worker "-poshdebug"

and the powershell language worker if that parameter is specified sets the AZFUNC_IS_POSHDEBUG environment variable (or whatever). Then in my code I can add:

if ($AZFUNC_IS_POSHDEBUG) {wait-debugger}

And that way my code is the same in both debug and production. I personally would place this at the top of pretty much every function so when debugging it stops at the top of the script, and since VSCode breakpoints work from then on, I’d just click continue once and get to where I really wanted to be, without having to constantly “add debugger line, save, debug,remove debugger line,save,continue”

Just some thoughts unless there’s already a plan for GA. Thanks!

EDIT: The environment variable should be AZURE_FUNCTIONS_ENVIRONMENT since it already exists for this “purpose”

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JustinGrotecommented, Apr 18, 2022

Breakpoints now work in 2022.4.1-preview FINALLY! Thanks to @seeminglyscience for the work on this. Closing this issue unless I come across a significant enough regression.

https://github.com/PowerShell/vscode-powershell/releases/tag/untagged-0b17b3c1ec11c7dda14a

1reaction
daxian-dbwcommented, May 8, 2019

@JustinGrote Of course, as I mentioned in https://github.com/Azure/azure-functions-powershell-worker/issues/204#issuecomment-489368383, that PR is the first step toward the desired experience.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve F# Debugging experience Visual Studio/Code
The Visual Studio (and Code) Debugging experience is much worse for F# than C#. Most of the time it is impossible to inspect...
Read more >
A new home for the Debug Adapter Protocol
This blog provides some background about protocols, the Debug Adapter Protocol, and the motivation behind the move. Why the need for decoupling ...
Read more >
VS Code Community Discussions for Extension Authors
Announcing the official launch of VS Code Community Discussions, a place for extension authors to connect.
Read more >
Introducing Logpoints and auto-attach
Over the past few months we have been busy improving the debugging experience in Visual Studio Code, and in this post, I'm going...
Read more >
What's New for Chrome debugging in VS Code
Over the recent months, we have been busy improving the Chrome debugging experience for Visual Studio Code, and today we are happy to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found