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

Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858) #387

Closed
ahmadawais opened this issue May 19, 2018 · 34 comments
Labels

Comments

@ahmadawais
Copy link

I'm facing a weird issue.

Error:

Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858).
VSCode 1.23.1
MacOS 
Node: 10.1.0
OS: macOS Sierra
npm: 6.0.1
Chrome: 66.0.3359.181

Launch.json

{
	"version": "0.2.0",
	"configurations": [
		{
			"name": "Attach to JavaScript Functions",
			"type": "node",
			"request": "attach",
			"port": 5858,
			"protocol": "inspector",
			"preLaunchTask": "runFunctionsHost"
		}
	]
}

image

Trying to create an Azure function.

Several errors in my terminal output:

> Executing task: func host start <


                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Hosting environment: Production
Content root path: /Users/$USER/Documents/Web/Sandbox/afn
Now listening on: http://localhost:7071
Application started. Press Ctrl+C to shut down.
[5/19/18 8:24:57 PM] Reading host configuration file '/Users/$USER/Documents/Web/Sandbox/afn/host.json'
[5/19/18 8:24:57 PM] Host configuration file read:
[5/19/18 8:24:57 PM] {}
[5/19/18 8:24:57 PM] Starting Host (HostId=ahmadsmacbookpro-763423413, InstanceId=50434726-525b-4afa-9566-a137447a193f, Version=2.0.11651.0, ProcessId=98058, AppDomainId=1, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=)
[5/19/18 8:24:57 PM] Unable to configure java worker. Could not find JAVA_HOME app setting.
[5/19/18 8:24:57 PM]
[5/19/18 8:24:57 PM] Could not configure language worker Java.
[5/19/18 8:24:57 PM]
[5/19/18 8:24:57 PM] Start Process: node  --inspect=5858 "/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.25/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 55405 --workerId 33587250-9112-4a07-a373-8572a42396da --requestId 53993c42-bc16-4358-ab64-074a66876e11
[5/19/18 8:24:57 PM] Debugger listening on port 5858.
[5/19/18 8:24:57 PM] Warning: This is an experimental feature and could change at any time.
[5/19/18 8:24:57 PM] To start debugging, open the following URL in Chrome:
[5/19/18 8:24:57 PM]     chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:5858/a514a2fa-8b05-47f9-b371-79afd68b44c5
[5/19/18 8:24:57 PM] Generating 1 job function(s)
[5/19/18 8:24:57 PM] Found the following functions:
[5/19/18 8:24:57 PM] Host.Functions.HttpTriggerJS
[5/19/18 8:24:57 PM]
[5/19/18 8:24:57 PM] Host initialized (656ms)
[5/19/18 8:24:57 PM] azure-functions-nodejs-worker officially supports node version >=8.4.0. Current version v7.10.0.
[5/19/18 8:24:57 PM] To install required native modules for v7.10.0, install node-pre-gyp via 'npm i -g node-pre-gyp'.
[5/19/18 8:24:57 PM] Navigate to '<node-worker-dir>/grpc' and run 'node-pre-gyp install'
[5/19/18 8:24:57 PM] Host started (687ms)
[5/19/18 8:24:57 PM] Job host started
[5/19/18 8:24:57 PM] Couldn't require bundle, falling back to Worker.js. Error: Cannot find module '/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.25/workers/node/grpc/src/node/extension_binary/node-v51-darwin-x64/grpc_node.node'
[5/19/18 8:24:57 PM] module.js:472
[5/19/18 8:24:57 PM]     throw err;
[5/19/18 8:24:57 PM]     ^
[5/19/18 8:24:57 PM] Error: Cannot find module './Worker.js'
[5/19/18 8:24:57 PM]     at Function.Module._resolveFilename (module.js:470:15)
[5/19/18 8:24:57 PM]     at Function.Module._load (module.js:418:25)
[5/19/18 8:24:57 PM]     at Module.require (module.js:498:17)
[5/19/18 8:24:57 PM]     at require (internal/module.js:20:19)
[5/19/18 8:24:57 PM]     at Object.<anonymous> (/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.25/workers/node/dist/src/nodejsWorker.js:8:14)
[5/19/18 8:24:57 PM]     at Module._compile (module.js:571:32)
[5/19/18 8:24:57 PM]     at Object.Module._extensions..js (module.js:580:10)
[5/19/18 8:24:57 PM]     at Module.load (module.js:488:32)
[5/19/18 8:24:57 PM]     at tryModuleLoad (module.js:447:12)
[5/19/18 8:24:57 PM]     at Function.Module._load (module.js:439:3)
[5/19/18 8:24:57 PM] Worker encountered an error.
[5/19/18 8:24:57 PM] Worker process with pid 98060 exited with code 1.
[5/19/18 8:24:57 PM] Start Process: node  --inspect=5858 "/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.25/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 55405 --workerId fa3f45e4-eb03-424a-903f-e3e25ee692ad --requestId e3ec9f82-c612-4706-be84-aff784a88ff4
[5/19/18 8:24:57 PM] Debugger listening on port 5858.
[5/19/18 8:24:57 PM] Warning: This is an experimental feature and could change at any time.
[5/19/18 8:24:57 PM] To start debugging, open the following URL in Chrome:
[5/19/18 8:24:57 PM]     chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:5858/XXXXX-0e65-47d6-b569-63693636c245
Listening on http://localhost:7071/
Hit CTRL-C to exit...

Http Functions:

        HttpTriggerJS: http://localhost:7071/api/HttpTriggerJS

[5/19/18 8:24:57 PM] azure-functions-nodejs-worker officially supports node version >=8.4.0. Current version v7.10.0.
[5/19/18 8:24:57 PM] To install required native modules for v7.10.0, install node-pre-gyp via 'npm i -g node-pre-gyp'.
[5/19/18 8:24:57 PM] Navigate to '<node-worker-dir>/grpc' and run 'node-pre-gyp install'
[5/19/18 8:24:58 PM] Couldn't require bundle, falling back to Worker.js. Error: Cannot find module '/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.25/workers/node/grpc/src/node/extension_binary/node-v51-darwin-x64/grpc_node.node'
[5/19/18 8:24:58 PM] module.js:472
[5/19/18 8:24:58 PM]     throw err;
[5/19/18 8:24:58 PM]     ^
[5/19/18 8:24:58 PM] Error: Cannot find module './Worker.js'
[5/19/18 8:24:58 PM]     at Function.Module._resolveFilename (module.js:470:15)
[5/19/18 8:24:58 PM]     at Function.Module._load (module.js:418:25)
[5/19/18 8:24:58 PM]     at Module.require (module.js:498:17)
[5/19/18 8:24:58 PM]     at require (internal/module.js:20:19)
[5/19/18 8:24:58 PM]     at Object.<anonymous> (/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.25/workers/node/dist/src/nodejsWorker.js:8:14)
[5/19/18 8:24:58 PM]     at Module._compile (module.js:571:32)
[5/19/18 8:24:58 PM]     at Object.Module._extensions..js (module.js:580:10)
[5/19/18 8:24:58 PM]     at Module.load (module.js:488:32)
[5/19/18 8:24:58 PM]     at tryModuleLoad (module.js:447:12)
[5/19/18 8:24:58 PM]     at Function.Module._load (module.js:439:3)
[5/19/18 8:24:58 PM] Worker encountered an error.
[5/19/18 8:24:58 PM] Worker process with pid 98062 exited with code 1.
[5/19/18 8:24:58 PM] Start Process: node  --inspect=5858 "/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.25/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 55405 --workerId e50dd0da-8419-49b8-8a25-87520752a694 --requestId 71f7ab6c-a836-4d57-b0f8-8f9d541f6b4d
[5/19/18 8:24:58 PM] Debugger listening on port 5858.
[5/19/18 8:24:58 PM] Warning: This is an experimental feature and could change at any time.
[5/19/18 8:24:58 PM] To start debugging, open the following URL in Chrome:
[5/19/18 8:24:58 PM]     chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:5858/as-631d-4dfe-b7da-7e9ccf4379e9
[5/19/18 8:24:58 PM] azure-functions-nodejs-worker officially supports node version >=8.4.0. Current version v7.10.0.
[5/19/18 8:24:58 PM] To install required native modules for v7.10.0, install node-pre-gyp via 'npm i -g node-pre-gyp'.
[5/19/18 8:24:58 PM] Navigate to '<node-worker-dir>/grpc' and run 'node-pre-gyp install'
[5/19/18 8:24:58 PM] Couldn't require bundle, falling back to Worker.js. Error: Cannot find module '/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.25/workers/node/grpc/src/node/extension_binary/node-v51-darwin-x64/grpc_node.node'
[5/19/18 8:24:58 PM] module.js:472
[5/19/18 8:24:58 PM]     throw err;
[5/19/18 8:24:58 PM]     ^
[5/19/18 8:24:58 PM] Error: Cannot find module './Worker.js'
[5/19/18 8:24:58 PM]     at Function.Module._resolveFilename (module.js:470:15)
[5/19/18 8:24:58 PM]     at Function.Module._load (module.js:418:25)
[5/19/18 8:24:58 PM]     at Module.require (module.js:498:17)
[5/19/18 8:24:58 PM]     at require (internal/module.js:20:19)
[5/19/18 8:24:58 PM]     at Object.<anonymous> (/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.25/workers/node/dist/src/nodejsWorker.js:8:14)
[5/19/18 8:24:58 PM]     at Module._compile (module.js:571:32)
[5/19/18 8:24:58 PM]     at Object.Module._extensions..js (module.js:580:10)
[5/19/18 8:24:58 PM]     at Module.load (module.js:488:32)
[5/19/18 8:24:58 PM]     at tryModuleLoad (module.js:447:12)
[5/19/18 8:24:58 PM]     at Function.Module._load (module.js:439:3)
[5/19/18 8:24:58 PM] Worker encountered an error.
[5/19/18 8:24:58 PM] Worker process with pid 98063 exited with code 1.

Help.

@thesilverbadger
Copy link

I had the same issue, and it seems partially related to the Node version installed (I had v10). I believe the functions runtime only supports v8.

My functions now run at least, but I still get the debugger error

@ahmadawais
Copy link
Author

@thesilverbadger that's right. I have v10 installed.

@apulliam
Copy link

I'm getting the same error with Node 8.11.2 and v2 runtime on Windows. v1 runtime works fine as long as I set protocol to "legacy" in launch.json. I can't connect the vscode debugger to v2 runtime using either "legacy" or "inspector" protocol.

@ejizba
Copy link
Contributor

ejizba commented May 21, 2018

This only reproduces for me on the latest version of the func cli. As a workaround, you can install the previous version with this command:

@ahmelsayed @fabiocav any idea why the .26 release would've broken javascript debugging in VS Code?

@fabiocav
Copy link

There were some changes with the Node worker in this release.

@EricJizbaMSFT , I'm assuming you see the issue if Node 8.4.0 or higher is installed, is that correct?

/cc @mhoeger as she might have more information on the issue.

@thesilverbadger
Copy link

Can confirm that 2.0.1-beta.25 fixes the issue for me, running Node 8.11.2 and VS Code 1.23.1

@ejizba
Copy link
Contributor

ejizba commented May 21, 2018

I'm on node v8.6. It seems like '--inspect=5858' isn't being passed in to the node process like it used to be.

This is what I see in the log for .25:

[5/21/18 4:40:40 PM] Start Process: node  --inspect=5858 "/usr/local/lib/node_modules/azure-functions-core-tools/bin/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 51227 --workerId 04953aea-a873-4869-a00b-9eb63d076fae --requestId 149e08dc-3a23-478e-9628-7961ee098ea4

This is what I see in the log for .26:

[5/21/18 4:35:45 PM] Start Process: node  "/usr/local/lib/node_modules/azure-functions-core-tools/bin/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 51085 --workerId 979575bb-fd9e-43aa-bfa8-c1a7df12064f --requestId 59b1b809-55d4-4bd3-9ed8-2a6c866df4c0 --grpcMaxMessageLength 134217728

@mhoeger
Copy link

mhoeger commented May 21, 2018

It looks like this PR introduced a change in the way we check for debug port: Azure/azure-functions-host@980107f.

It seems like the issue may be more fundamental though, as adding the additional environment variable (see snippet below) which sets the --inspect param correctly does not attach a debugger correctly.

"options": { "env": { "workers:node:debug": "5858" } }

==CORRECTION: adding this does work==

I'm filing an issue for this against the runtime, cc @pragnagopa

@fabiocav
Copy link

Thank you @mhoeger! That makes sense. Can you link to the issue here to make it easier for others to track?

@EricJizbaMSFT we'll have another release very soon (we're iterating very quickly on a few items), and hopefully we can have this patched with the next drop

@ejizba
Copy link
Contributor

ejizba commented May 21, 2018

Awesome thanks! @fabiocav just to be clear - when you say "we can have this patched" do you mean it would be backwards compatible with the old behavior?

I don't entirely follow the changes mentioned by @mhoeger, but it would be difficult for our extension to change existing 'launch.json' or 'tasks.json' files, especially since users might've already customized them. We can certainly update our templates if need be, but that only affects new projects.

@fabiocav
Copy link

We'll discuss whether this would be fixed to be backwards compatible. It wouldn't be difficult to do that, but we only have a chance to make those kinds of changes while we're in preview, and keeping preview behavior for backwards compatibility is something we're trying to avoid. With that said, this wouldn't be problematic to keep, so I don't think it would be an issue.

@mhoeger
Copy link

mhoeger commented May 22, 2018

Correction to my comment earlier: adding the following property to a task in tasks.json will correctly attach the debugger:
"options": { "env": { "workers:node:debug": "5858" } }
(see Azure/azure-functions-host#2878 for details).

@EricJizbaMSFT - we're still looking into being backwards compatible, although it might not be in the next release.

@bastiankistner
Copy link

bastiankistner commented May 23, 2018

The env solution doesn't work for me :(

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach by Process ID",
      "processId": "${command:PickProcess}"
    },
    {
      "name": "Attach to JavaScript Functions",
      "type": "node",
      "request": "attach",
      "port": 5858,
      "protocol": "inspector",
      "preLaunchTask": "runFunctionsHost",
    }
  ]
}

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "options": {
        "cwd": "dist",
        "env": {
          "workers:node:debug": "5858"
        }
      },
      "label": "Run Functions Host",
      "identifier": "runFunctionsHost",
      "type": "shell",
      "command": "func host start",
      "isBackground": true,
      "presentation": {
        "reveal": "always"
      },
      "problemMatcher": [
        {
          "owner": "azureFunctions",
          "pattern": [
            {
              "regexp": "\\b\\B",
              "file": 1,
              "location": 2,
              "message": 3
            }
          ],
          "background": {
            "activeOnStart": true,
            "beginsPattern": "^.*Stopping host.*",
            "endsPattern": "^.*Job host started.*"
          }
        }
      ]
    }
  ]
}

Note: using Attach by Process ID to manually attach the debugger works. But it does not connect automatically when the task is launching. This would be very helpful for code reload on change.

@ejizba
Copy link
Contributor

ejizba commented May 23, 2018

@mhoeger The 'env' option you described is also not working for me.

ejizba added a commit that referenced this issue May 23, 2018
The release is due to [this bug](#387), but doesn't actually fix the bug itself (the real fix needs to be in the func cli). However, this release mitigates the bug by giving us the ability to 'turn off' the prompt to install the latest func cli (since Nathan [just changed](#391) it to an aka.ms link).

I did a few additional things:
1. Stop displaying errors in the output channel. I think they're more confusing than helpful (NOTE: `this.suppressErrorDisplay` is still on even though I removed the try/catch, so users will NOT see these errors)
1. Temporarily hard-code the kudu package to the version used with the last release. I want to keep changes as small as possible for this bug-fix release
@fabiocav
Copy link

NOTE: When running on a non-Windows machine, the environment name should be workers__node__Debug. This is case sensitive, so the capital D is important.

@jdneo
Copy link
Member

jdneo commented May 24, 2018

Same issue in Java. It looks like the function cli does not start the JVM in debug mode.

@bastiankistner
Copy link

bastiankistner commented May 24, 2018

I can confirm that setting workers__node__Debug instead of workers:node:debug works like a charm. Thank you @fabiocav and @mhoeger

Is this a general convention between windows and non-windows operating systems? I once wondered why typescript @types usually convert subsequent slashes into double underscores. Does this somehow relate with each other?

@ejizba
Copy link
Contributor

ejizba commented May 31, 2018

Closing this issue as it has been fixed in the latest version of the func cli. The workarounds mentioned above are no longer necessary - simply update your func cli:

npm i -g azure-functions-core-tools@core

or

brew upgrade azure-functions-core-tools

@ejizba ejizba closed this as completed May 31, 2018
@ahmadawais
Copy link
Author

@EricJizbaMSFT I can confirm that it's still not working for me on MacOS. :(

I ran

brew upgrade azure-functions-core-tools

OUTPUT

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/cask).
No changes to formulae.

Error: azure/functions/azure-functions-core-tools 2.0.1-beta.28 already installed

When I create an Azure function, let's say HTTP triggered JavaScript based function. And press play in the debug the following is what I get as output in my terminal.

TERMINAL OUTPUT (CLICK TO EXPAND!)
> Executing task: func host start <


                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Hosting environment: Production
Content root path: /Users/ahmadawais/Documents/Web/Sandbox/demo-azure-func
Now listening on: http://localhost:7071
Application started. Press Ctrl+C to shut down.
[5/31/18 11:58:20 PM] Reading host configuration file '/Users/ahmadawais/Documents/Web/Sandbox/demo-azure-func/host.json'
[5/31/18 11:58:20 PM] Host configuration file read:
[5/31/18 11:58:20 PM] {}
[5/31/18 11:58:20 PM] Starting Host (HostId=ahmadsmacbookpro-1530556110, InstanceId=2485c474-9ed2-4041-b716-b11e819adb18, Version=2.0.11776.0, ProcessId=60925, AppDomainId=1, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=)
[5/31/18 11:58:20 PM] Loading all the worker providers from the default workers directory: /usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers
[5/31/18 11:58:20 PM] Found worker config: /usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/python/worker.config.json
[5/31/18 11:58:20 PM] Will load worker provider for language: python
[5/31/18 11:58:20 PM] Start Process: node  --inspect=5858 "/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 64239 --workerId eb429ee4-d00a-4aa9-8ea1-3b9b62facfb0 --requestId 7bd13f1f-4b9b-478f-89ca-61e32683718d --grpcMaxMessageLength 134217728
[5/31/18 11:58:20 PM] Generating 1 job function(s)
[5/31/18 11:58:20 PM] Found the following functions:
[5/31/18 11:58:20 PM] Host.Functions.HttpTriggerJS
[5/31/18 11:58:20 PM]
[5/31/18 11:58:20 PM] Host initialized (834ms)
[5/31/18 11:58:20 PM] Host started (881ms)
[5/31/18 11:58:20 PM] Job host started
[5/31/18 11:58:20 PM] Debugger listening on port 5858.
[5/31/18 11:58:20 PM] Warning: This is an experimental feature and could change at any time.
[5/31/18 11:58:20 PM] To start debugging, open the following URL in Chrome:
[5/31/18 11:58:20 PM]     chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:5858/38025454-03f3-4ff6-a096-f10c16bf46da
Listening on http://localhost:7071/
Hit CTRL-C to exit...

Http Functions:

        HttpTriggerJS: http://localhost:7071/api/HttpTriggerJS

[5/31/18 11:58:21 PM] azure-functions-nodejs-worker officially supports node version >=8.4.0. Current version v7.10.0.
[5/31/18 11:58:21 PM] To install required native modules for v7.10.0, install node-pre-gyp via 'npm i -g node-pre-gyp'.
[5/31/18 11:58:21 PM] Navigate to '<node-worker-dir>/grpc' and run 'node-pre-gyp install'
[5/31/18 11:58:21 PM] Couldn't require bundle, falling back to Worker.js. Error: Cannot find module '/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/node/grpc/src/node/extension_binary/node-v51-darwin-x64/grpc_node.node'
[5/31/18 11:58:21 PM] module.js:472
[5/31/18 11:58:21 PM]     throw err;
[5/31/18 11:58:21 PM]     ^
[5/31/18 11:58:21 PM] Error: Cannot find module './Worker.js'
[5/31/18 11:58:21 PM]     at Function.Module._resolveFilename (module.js:470:15)
[5/31/18 11:58:21 PM]     at Function.Module._load (module.js:418:25)
[5/31/18 11:58:21 PM]     at Module.require (module.js:498:17)
[5/31/18 11:58:21 PM]     at require (internal/module.js:20:19)
[5/31/18 11:58:21 PM]     at Object.<anonymous> (/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/node/dist/src/nodejsWorker.js:8:14)
[5/31/18 11:58:21 PM]     at Module._compile (module.js:571:32)
[5/31/18 11:58:21 PM]     at Object.Module._extensions..js (module.js:580:10)
[5/31/18 11:58:21 PM]     at Module.load (module.js:488:32)
[5/31/18 11:58:21 PM]     at tryModuleLoad (module.js:447:12)
[5/31/18 11:58:21 PM]     at Function.Module._load (module.js:439:3)
[5/31/18 11:58:21 PM] Worker encountered an error.
[5/31/18 11:58:21 PM] Worker process with pid 60936 exited with code 1.
[5/31/18 11:58:21 PM] Start Process: node  --inspect=5858 "/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 64239 --workerId 13d9c4eb-ef83-4269-a3a4-96c2d21d36f7 --requestId e1d8dc1b-f79c-49f6-af53-0f06131750b1 --grpcMaxMessageLength 134217728
[5/31/18 11:58:21 PM] Debugger listening on port 5858.
[5/31/18 11:58:21 PM] Warning: This is an experimental feature and could change at any time.
[5/31/18 11:58:21 PM] To start debugging, open the following URL in Chrome:
[5/31/18 11:58:21 PM]     chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:5858/404b2994-7fe4-482c-a4d9-47b162c9c016
[5/31/18 11:58:21 PM] azure-functions-nodejs-worker officially supports node version >=8.4.0. Current version v7.10.0.
[5/31/18 11:58:21 PM] To install required native modules for v7.10.0, install node-pre-gyp via 'npm i -g node-pre-gyp'.
[5/31/18 11:58:21 PM] Navigate to '<node-worker-dir>/grpc' and run 'node-pre-gyp install'
[5/31/18 11:58:21 PM] Couldn't require bundle, falling back to Worker.js. Error: Cannot find module '/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/node/grpc/src/node/extension_binary/node-v51-darwin-x64/grpc_node.node'
[5/31/18 11:58:21 PM] module.js:472
[5/31/18 11:58:21 PM]     throw err;
[5/31/18 11:58:21 PM]     ^
[5/31/18 11:58:21 PM] Error: Cannot find module './Worker.js'
[5/31/18 11:58:21 PM]     at Function.Module._resolveFilename (module.js:470:15)
[5/31/18 11:58:21 PM]     at Function.Module._load (module.js:418:25)
[5/31/18 11:58:21 PM]     at Module.require (module.js:498:17)
[5/31/18 11:58:21 PM]     at require (internal/module.js:20:19)
[5/31/18 11:58:21 PM]     at Object.<anonymous> (/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/node/dist/src/nodejsWorker.js:8:14)
[5/31/18 11:58:21 PM]     at Module._compile (module.js:571:32)
[5/31/18 11:58:21 PM]     at Object.Module._extensions..js (module.js:580:10)
[5/31/18 11:58:21 PM]     at Module.load (module.js:488:32)
[5/31/18 11:58:21 PM]     at tryModuleLoad (module.js:447:12)
[5/31/18 11:58:21 PM]     at Function.Module._load (module.js:439:3)
[5/31/18 11:58:21 PM] Worker encountered an error.
[5/31/18 11:58:21 PM] Worker process with pid 60938 exited with code 1.
[5/31/18 11:58:21 PM] Start Process: node  --inspect=5858 "/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 64239 --workerId 730f8528-4b09-4340-8d85-4f3e67a7b033 --requestId cbc03b01-628f-436c-bf82-3eafd59fd699 --grpcMaxMessageLength 134217728
[5/31/18 11:58:21 PM] Debugger listening on port 5858.
[5/31/18 11:58:21 PM] Warning: This is an experimental feature and could change at any time.
[5/31/18 11:58:21 PM] To start debugging, open the following URL in Chrome:
[5/31/18 11:58:21 PM]     chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:5858/ccb6f279-c7d1-4bfe-a13a-49f79db2dbf7
[5/31/18 11:58:21 PM] azure-functions-nodejs-worker officially supports node version >=8.4.0. Current version v7.10.0.
[5/31/18 11:58:21 PM] To install required native modules for v7.10.0, install node-pre-gyp via 'npm i -g node-pre-gyp'.
[5/31/18 11:58:21 PM] Navigate to '<node-worker-dir>/grpc' and run 'node-pre-gyp install'
[5/31/18 11:58:21 PM] Couldn't require bundle, falling back to Worker.js. Error: Cannot find module '/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/node/grpc/src/node/extension_binary/node-v51-darwin-x64/grpc_node.node'
[5/31/18 11:58:21 PM] module.js:472
[5/31/18 11:58:21 PM]     throw err;
[5/31/18 11:58:21 PM]     ^
[5/31/18 11:58:21 PM] Error: Cannot find module './Worker.js'
[5/31/18 11:58:21 PM]     at Function.Module._resolveFilename (module.js:470:15)
[5/31/18 11:58:21 PM]     at Function.Module._load (module.js:418:25)
[5/31/18 11:58:21 PM]     at Module.require (module.js:498:17)
[5/31/18 11:58:21 PM]     at require (internal/module.js:20:19)
[5/31/18 11:58:21 PM]     at Object.<anonymous> (/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/node/dist/src/nodejsWorker.js:8:14)
[5/31/18 11:58:21 PM]     at Module._compile (module.js:571:32)
[5/31/18 11:58:21 PM]     at Object.Module._extensions..js (module.js:580:10)
[5/31/18 11:58:21 PM]     at Module.load (module.js:488:32)
[5/31/18 11:58:21 PM]     at tryModuleLoad (module.js:447:12)
[5/31/18 11:58:21 PM]     at Function.Module._load (module.js:439:3)
[5/31/18 11:58:21 PM] Worker encountered an error.
[5/31/18 11:58:21 PM] Worker process with pid 60939 exited with code 1.Details!

And the same error

image

Help.

@ahmadawais
Copy link
Author

@mhoeger I tried what you suggested along with @fabiocav but stil nothing. Same errors.

@ejizba
Copy link
Contributor

ejizba commented Jun 1, 2018

@ahmadawais I think this is the key part of the log for you:

azure-functions-nodejs-worker officially supports node version >=8.4.0. Current version v7.10.0.
[5/31/18 11:58:21 PM] To install required native modules for v7.10.0, install node-pre-gyp via 'npm i -g node-pre-gyp'.
[5/31/18 11:58:21 PM] Navigate to '<node-worker-dir>/grpc' and run 'node-pre-gyp install'

I would recommend updating your version of Node, but if you need to stick to v7.10.0 then you can follow the instructions to 'install required native modules'

@ahmadawais
Copy link
Author

ahmadawais commented Jun 1, 2018

@EricJizbaMSFT That's the thing. As you can check from the first comment in this issue I am using Node v10 locally.

VSCode 1.23.1
MacOS 
Node: 10.1.0
OS: macOS Sierra
npm: 6.0.1
Chrome: 66.0.3359.181

I have also tried with Node 9.7.1 and this message is beyond me I don't know why I am getting this error. Any help? Pretty sure this is a bug.

@ejizba
Copy link
Contributor

ejizba commented Jun 1, 2018

Do you see v10 when you run node --version from the command prompt? Is it set correctly on your PATH?
screen shot 2018-06-01 at 9 16 31 am

@pragnagopa
Copy link
Member

pragnagopa commented Jun 1, 2018

@ahmadawais - This issue was tracking broken debug experience from VSCode, which is now fixed in the latest version of CLI 2.0.1-beta.28. The issue you are running into might be due to node version. Can you please open a new issue in https://github.com/Azure/azure-functions-nodejs-worker repo?

@ahmadawais
Copy link
Author

ahmadawais commented Jun 1, 2018 via email

@ejizba
Copy link
Contributor

ejizba commented Jun 1, 2018

@ahmadawais I'll echo what @pragnagopa said. There were two issues here - one directly related to VS Code (which was fixed) and one specific to the azure-functions-nodejs-worker. I don't think there's anything we could do from the VS Code side to fix your issue and I recommend investigating it further in the repo she mentioned: https://github.com/Azure/azure-functions-nodejs-worker

@ahmadawais
Copy link
Author

Sure done Azure/azure-functions-nodejs-worker#89

@mikeclymer
Copy link

mikeclymer commented Jun 8, 2018

@ahmadawais - This line in your error log shows that VS Code thinks your version of node is an unsupported older version (I think).

5/19/18 8:24:58 PM] Couldn't require bundle, falling back to Worker.js. Error: Cannot find module '/usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.25/workers/node/grpc/src/node/extension_binary/node-v51-darwin-x64/grpc_node.node'

I was experiencing a similar issue with VS Code thinking I was using v10.x of node. I found that it is due to how nvm interacts with shell environments and how VS Code loads the node version based on what is aliased as the default. See this SO Q&A for more info: Visual Studio Code to use node version specified by NVM

The only suggested solution that worked for me was to set nvm alias default 8.11.2 in the terminal and restart VS Code. Not my preferred choice, but it works. You need to set your default alias to something in the v8.x range. It doesn't look like extension binaries are available for later versions of node.

> ls -l /usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.28/workers/node/grpc/src/node/extension_binary
total 0
drwxr-xr-x  3 someone  staff  96 Jun  7 19:43 node-v48-win32-ia32
drwxr-xr-x  3 someone  staff  96 Jun  7 19:43 node-v57-darwin-ia32
drwxr-xr-x  3 someone  staff  96 Jun  7 19:43 node-v57-darwin-x64
drwxr-xr-x  3 someone  staff  96 Jun  7 19:43 node-v57-linux-ia32
drwxr-xr-x  3 someone  staff  96 Jun  7 19:43 node-v57-linux-x64
drwxr-xr-x  3 someone  staff  96 Jun  7 19:43 node-v57-win32-ia32
drwxr-xr-x  3 someone  staff  96 Jun  7 19:43 node-v57-win32-x64

NOTE: Setting the runtimeExecutable attribute in launch.json, for the debugger, will not work due to it only being available for request types of launch, not attach. See: Launch configuration attributes

@EricJizbaMSFT and @pragnagopa would making the runtimeExecutable attribute available for request types of attach be feasible? I would much rather set that in the config than muck with my nvm default.

@ahmadawais
Copy link
Author

ahmadawais commented Jun 8, 2018

UPDATE:

Oh wow! I just figured it out. It's working fine now.

So, here's what happened. I have node -v reporting version 8.11.2 everywhere in the VSCode terminal, and in iTerm2. But I had another project open in VSCode which I was working on earlier. That had the terminal open as well. So, when I tried, that one reported 10.1.0 so instead of reloading VSCode, I quit and started it from scratch. That fixed it.

Also, opened a PR to improve the error message. Azure/azure-functions-nodejs-worker#92

Thanks to @mhoeger 🙌 and all of you!

@ejizba
Copy link
Contributor

ejizba commented Jun 18, 2018

@mikeclymer thanks for the help. In terms of this:

would making the runtimeExecutable attribute available for request types of attach be feasible? I would much rather set that in the config than muck with my nvm default.

You might be able to use environment variables in your launch.json to get this same effect, but please file a separate issue if you're still interested and we can investigate further

@v-dantch v-dantch reopened this Jul 6, 2018
@ejizba
Copy link
Contributor

ejizba commented Jul 6, 2018

@v-dantch this is an old issue and has already been fixed so I'll re-close this. We have run into a similar issue, but it has a different cause and is being tracked with these issues:
#438
#436

@ejizba ejizba closed this as completed Jul 6, 2018
@markheath
Copy link

I am running into this same issue Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858 on Windows 10, with Azure Functions Core Tools (2.0.1-beta.31) and node v10.7.0.

I am able to debug if I manually attach to the node process, but any reason why it's not working for me even though I have the latest tools installed?

@ejizba
Copy link
Contributor

ejizba commented Jul 18, 2018

@markheath There's a known bug in 2.0.1-beta.31 for node functions. Please try adding "NODE_OPTIONS": "--inspect=5858" to your local.settings.json file as a workaround. See #438 for more information and let me know if that doesn't work for you

@markheath
Copy link

@EricJizbaMSFT magic! that did the trick. Thanks for the speedy response.

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