Since I updated to version 2.0.1-beta.30, I can't run debugging from VSCode. In the console log after I ran func host start, there is no --inspect=5858 flag at Start Process nodejsWorker.
I already tried func host start --language-worker -- "--inspect=5858" but still no inspect flag. Did I miss something?
I installed it via Homebrew (2.0.1-beta.31)
@pragnagopa This looks like a regression in the host for non-Windows platforms.
This command func host start --language-worker -- "--inspect=5858" works find on Windows, I see
Debugger listening on ws://127.0.0.1:5656/4a42740b-a375-401f-afa2-5658c129ff0d
For help see https://nodejs.org/en/docs/inspector
But on linux, I can see that the cli setting languageWorkers__node__arguments = --inspect=5858, but I don't see the argument passed along to node process.
thanks @fabiocav I think we understand the issue. It's a casing difference between Windows and *nix machines.
@ntchjb you can try NODE_OPTIONS="--inspect=5656" func start instead which will bypass the functions cli logis and set the inspection port to whatever you set it. (_note this won't work if you get the cli from npm due to 2 node processes running_)
OK, I will use environment variables method instead. I think for cli that is installed from npm, we may set NODE_OPTIONS in local.settings.json like this:
{
"Values": {
...,
"NODE_OPTIONS": "--inspect=5858"
}
}
So the NODE_OPTIONS will be set on nodejsWorker.js but not on func.
Thanks for replying.
That's a good point. Will get a fix in for this issue in the next release.
@ahmelsayed The same issue seems to be occurring for .NET Core functions. What's the workaround in that case?
Edit: Sorry never mind. Doesn't seem to be the same issue.
Fixed in 8da9491d9866188e4661318e33c469ded8ad49b0
I'm using 2.0.1-beta.33 (on mac) and still seeing this. Is it to be expected?
what are you seeing?
Says the debugger failed to attach to port 5858 and I have to add this to my local.settings.json for it to work:
"NODE_OPTIONS": "--inspect=5858"
In VS Code
I just tried on a mac with beta.33 and it worked fine.
func start --language-worker -- "--inspect=5858"
Then attach to that port from vscode worked
Yep seems to be an issue with the VS Code template (@fiveisprime). The default task is:
{
"label": "Run Functions Host",
"identifier": "runFunctionsHost",
"type": "shell",
"command": "func host start",
"options": {
"env": {
"languageWorkers:node:arguments": "--inspect=5858"
}
},
...
but if I change to this it works
{
"label": "Run Functions Host",
"identifier": "runFunctionsHost",
"type": "shell",
"command": "func host start --language-worker -- \"--inspect=5858\"",
"options": {
"env": {
"languageWorkers:node:arguments": "--inspect=5858"
}
},
Expect that env variable isn't doing what is expected.
@jeffhollan - Did you try updating VS code. I have version 1.25.1 and that contains the right setting.
An update shipped last week that should handle this. You may need to re-initialize the local app to get the correct config. You can re-run the project creation to overwrite the task config.
Were you prompted to update your config?
@jeffhollan @ahmelsayed we're intentionally not using func host start --language-worker -- "--inspect=5858" because it requires FUNCTIONS_WORKER_RUNTIME to be set in local.settings.json. We can't use local.settings.json for any debugging information because it's not tracked in source control. We're waiting for this to be fixed: https://github.com/Azure/azure-functions-host/issues/3120
The default tasks.json is working for me on a mac with just the 'env' variable. @jeffhollan what version of node do you have?
Most helpful comment
OK, I will use environment variables method instead. I think for cli that is installed from npm, we may set
NODE_OPTIONSinlocal.settings.jsonlike this:So the
NODE_OPTIONSwill be set onnodejsWorker.jsbut not onfunc.Thanks for replying.