firebase --version
6.1.1
OS X
start a server on port 5001
http-server . -p 5001
and start the firebase serve function
firebase serve --only functions
Display an error saying 5001 already in used
https://github.com/firebase/firebase-tools/blob/master/src/functionsEmulator.js#L69
firebase serve --only functions --debug
[2018-11-23T03:53:25.384Z] ----------------------------------------------------------------------
[2018-11-23T03:53:25.387Z] Command: /Users/aurelien/.nvm/versions/node/v9.11.2/bin/node /Users/aurelien/.nvm/versions/node/v9.11.2/bin/firebase serve --only functions --debug
[2018-11-23T03:53:25.387Z] CLI Version: 6.1.1
[2018-11-23T03:53:25.387Z] Platform: darwin
[2018-11-23T03:53:25.387Z] Node Version: v9.11.2
[2018-11-23T03:53:25.388Z] Time: Thu Nov 22 2018 22:53:25 GMT-0500 (EST)
[2018-11-23T03:53:25.388Z] ----------------------------------------------------------------------
[2018-11-23T03:53:25.398Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2018-11-23T03:53:25.399Z] > authorizing via signed-in user
[2018-11-23T03:53:25.399Z] [iam] checking project codelab-firebase-b1a97 for permissions ["firebase.projects.get"]
[2018-11-23T03:53:25.400Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/codelab-firebase-b1a97:testIamPermissions
permissions=[firebase.projects.get]
[2018-11-23T03:53:25.799Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 23 Nov 2018 03:53:25 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39,35", accept-ranges=none, connection=close
[2018-11-23T03:53:25.801Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/codelab-firebase-b1a97
[2018-11-23T03:53:26.178Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 23 Nov 2018 03:53:26 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39,35", accept-ranges=none, connection=close
=== Serving from '/Users/aurelien/Web/nc-firebase/corrections'...
i functions: Preparing to emulate functions.
[2018-11-23T03:53:26.572Z] Fetching environment
[2018-11-23T03:53:26.576Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/918664590933:getServerAppConfig
[2018-11-23T03:53:26.838Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 23 Nov 2018 03:53:26 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="44,43,39,35", accept-ranges=none, connection=close
[2018-11-23T03:53:26.838Z] Starting @google-cloud/functions-emulator
[2018-11-23T03:53:26.871Z] Parsing function triggers
Warning: You're using Node.js v9.11.2 but Google Cloud Functions only supports v6.11.5.
[2018-11-23T03:53:27.007Z] Error while deploying to emulator: TypeError: Cannot read property 'call' of undefined
TypeError: Cannot read property 'call' of undefined
at Promise (/Users/aurelien/Web/firebase-tools/node_modules/@google-cloud/functions-emulator/src/client/rest-client.js:34:42)
at new Promise (<anonymous>)
at getService.then (/Users/aurelien/Web/firebase-tools/node_modules/@google-cloud/functions-emulator/src/client/rest-client.js:33:16)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:182:7)
⚠ functions: Failed to emulate contributions

I can have a look to fix it, if is relevant 😬
@gillespie59
What are you saying the actual behavior is? Am I correct in saying that the command continues and looks like it's serving, but in fact it is not?
Passing to @thechenky to take a look.
Just tried it on version 6.1.2 and I got
error: restPort (5001) is already in use
error: SUPERVISOR error Error: listen EADDRINUSE: address already in use 127.0.0.1:5000
at Server.setupListenHandle [as _listen2] (net.js:1290:14)
at listenInCluster (net.js:1338:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1471:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:62:10)
error: supervisorPort (5000) is already in use
when I tried to start up a second instance on the same port. The second instance also continued working as if it was still running correctly.
I will try tonight 😕
This is not working anymore on version 6.3.0.
firebase serve --only functions
I can edit my PR #1034 to fix problem and reviews 👍
@T3kstiil3 I can confirm this same behavior. If I start a server with python -m SimpleHTTPServer 5001 and run my functions (which can be served otherwise) I get very similar output.
@T3kstiil3 thank you for the detailed report and the PR that is in progress - we really appreciate your contributions to the firebase community.
@Memeriaj can you confirm that you saw a dedicated error in version 6.1.2? Do you see a different error when using 6.3.0? If so, then this would be a regression.
Yeah, that was the error that I saw in 6.1.2, but it isn't a dedicated error, that it still get spit up from a lower level. My comment was only intended to confirm that the issue was still happening (sorry for any confusion).
Just tried it on 6.3.0 and I got:
i functions: Preparing to emulate functions.
Warning: You're using Node.js v10.14.2 but Google Cloud Functions only supports v6.11.5.
error: SUPERVISOR error Error: listen EADDRINUSE: address already in use 127.0.0.1:5000
at Server.setupListenHandle [as _listen2] (net.js:1290:14)
at listenInCluster (net.js:1338:12)
at GetAddrInfoReqWrap.doListen [as callback] (net.js:1471:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:62:10)
error: supervisorPort (5000) is already in use
error: restPort (5001) is already in use
✔ functions: helloWorld: http://localhost:5000/another-hosting-test-email/us-central1/helloWorld
Now, both of those I did by running firebase serve --only functions in one terminal session and then starting up a second terminal instance and runnning firebase serve --only functions again. When I start a separate HTTP server on port 5001 and run firebase serve --only functions I end up with:
i functions: Preparing to emulate functions.
Warning: You're using Node.js v10.14.2 but Google Cloud Functions only supports v6.11.5.
⚠ functions: Failed to emulate helloWorld
i functions: No HTTPS functions found. Use firebase functions:shell if you would like to emulate other types of functions.
which seems to be exactly the same.
I believe that the Functions emulator is not failing gracefully when the port is taken. Apparently it'll outright error when the supervisor port is taken (5000) but only fail to emulate the HTTP functions if the HTTP port is taken (5001).
Currently when there is a port collision on the new functions emulator, it dies with An unexpected error. So this issue still exists, but in a slightly different form.
@abeisgoat does my PR fix this? https://github.com/firebase/firebase-tools/pull/1433