googlearchive / cloud-functions-emulator

A local emulator for deploying, running, and debugging Google Cloud Functions.
https://github.com/GoogleCloudPlatform/cloud-functions-emulator/wiki
Apache License 2.0
827 stars 115 forks source link

The port generate with functions inspect helloWorld it's not exposed correctly from the Docker container: #325

Open nietzscheson opened 5 years ago

nietzscheson commented 5 years ago

I have created this docker-compose environment for more information:

Environment details

Steps to reproduce

  1. First, run firebase serve in functions (docker-compose run firebase with the node command image: yarn --cwd functions serve):
    firebase serve --only functions -o 0.0.0.0 --port 8010
  2. To debug run:
functions deploy helloWorld -S functions -H
functions start --bindHost 0.0.0.0 --host 0.0.0.0
functions inspect helloWorld --host 0.0.0.0

The result:

Debugger for helloWorld listening on port 9229.
  1. When I trying open http://0.0.0.0:9229/json, this not works: This page isn’t working

Trying to avoid suspicion of whether the node --inspect does not work correctly, I expose port 9228 and exec the container: docker-compose exec node sh. I am going to functions: cd functions and I run the node inspector: node --inspect-brk = 0.0.0.0: 9228 index.js.

Now, when I trying open http://0.0.0.0:9228/json, this works:

[ {
  "description": "node.js instance",
  "devtoolsFrontendUrl": "chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=192.168.112.2:9228/b63b7903-7f2c-4304-ba02-63473ddffe90",
  "faviconUrl": "https://nodejs.org/static/favicon.ico",
  "id": "b63b7903-7f2c-4304-ba02-63473ddffe90",
  "title": "index.js",
  "type": "node",
  "url": "file:///app/functions/index.js",
  "webSocketDebuggerUrl": "ws://192.168.112.2:9228/b63b7903-7f2c-4304-ba02-63473ddffe90"
} ]

I really do not know what may be happening. The documentation is null. I have not found anything related. The information that there is to debug from a Docker container does not work for me. Any solution I will be grateful.

nietzscheson commented 5 years ago

I am certain that the solution is solving something here. By default, the node --inspect command points to the address http://127.0.0.1. When working with Docker images you must point to: http://0.0.0.0:

### supervisor.js. Line 320.
-        execArgv.push(`--inspect=${opts.port}`);
+        execArgv.push(`--inspect=${this.config.bindHost}:${opts.port}`);