Skip to content
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

How to set inspect port for nodejs #557

Closed
ntchjb opened this issue Jun 27, 2018 · 14 comments
Closed

How to set inspect port for nodejs #557

ntchjb opened this issue Jun 27, 2018 · 14 comments
Labels
Milestone

Comments

@ntchjb
Copy link

ntchjb commented Jun 27, 2018

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)

@ahmelsayed
Copy link
Contributor

@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.

@ahmelsayed
Copy link
Contributor

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)

@ntchjb
Copy link
Author

ntchjb commented Jun 29, 2018

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.

@ahmelsayed
Copy link
Contributor

That's a good point. Will get a fix in for this issue in the next release.

@ejizba
Copy link
Contributor

ejizba commented Jul 6, 2018

@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.

@ahmelsayed
Copy link
Contributor

Fixed in 8da9491

@jeffhollan
Copy link

jeffhollan commented Jul 29, 2018

I'm using 2.0.1-beta.33 (on mac) and still seeing this. Is it to be expected?

@ahmelsayed
Copy link
Contributor

what are you seeing?

@jeffhollan
Copy link

jeffhollan commented Jul 29, 2018

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

@ahmelsayed
Copy link
Contributor

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

@jeffhollan
Copy link

jeffhollan commented Jul 29, 2018

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.

@pragnagopa
Copy link
Member

@jeffhollan - Did you try updating VS code. I have version 1.25.1 and that contains the right setting.

@fiveisprime
Copy link
Member

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?

@ejizba
Copy link
Contributor

ejizba commented Jul 30, 2018

@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: Azure/azure-functions-host#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?

@Azure Azure locked as resolved and limited conversation to collaborators Dec 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants