googlearchive/cloud-functions-emulator

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

nietzscheson opened this issue · 1 comments

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

Environment details

  • OS: MacOS Mojave 10.14.1
  • Docker for Mac:
    • docker: 18.09.2, build 6247962
    • docker-compose: 1.23.2, build 1110ad01
  • Node.js version (docker image): node:8.14.0-alpine
  • npm version: 6.4.1
  • yarn version: 1.12.3
  • @google-cloud/functions-emulator version: 1.0.0-beta.6

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

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}`);