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

firebase-tools serve makes an error #1815

Closed
parsher opened this issue Nov 19, 2019 · 13 comments · Fixed by #1818
Closed

firebase-tools serve makes an error #1815

parsher opened this issue Nov 19, 2019 · 13 comments · Fixed by #1818

Comments

@parsher
Copy link

parsher commented Nov 19, 2019

[REQUIRED] Environment info

**firebase-tools: 7.8.0 (the latest)

**Platform: macOS

[REQUIRED] Test case

firebase functions

project

functions
index.js : exports.posts = functions.https.onRequest(require('./posts')); exports.posts = functions.https.onRequest(require('./accounts'));

posts : index.js : const app = require('express')(); const cors = require('cors'); app.use(cors({ origin: true })); app.get('/', async (req, res) => { });
accounts: index.js : const app = require('express')(); const cors = require('cors'); app.use(cors({ origin: true })); app.get('/', async (req, res) => { });

[REQUIRED] Steps to reproduce

firebase functions + express get / post methods
request multiple get requests, it makes errors.
it is only made on firebase-tools 7.8.0.
if I run the same codes on firebase-tools 7.7.0., it works fine.

[REQUIRED] Expected behavior

If I request multiple requests, it accepts well and perform.

[REQUIRED] Actual behavior

it makes an error

i  functions: Beginning execution of "accounts"
[2019-11-19T10:17:42.957Z] [runtime-status]  {"httpsTrigger":{},"name":"accounts","entryPoint":"accounts"}
[2019-11-19T10:17:42.957Z] [runtime-status] Running accounts in mode HTTPS {}
[2019-11-19T10:17:42.962Z] [functions] Runtime ready! Sending request!
[2019-11-19T10:17:42.968Z] [runtime-status] Ephemeral server used! {}
[2019-11-19T10:17:43.003Z] [runtime-status] Ephemeral server survived. {}
[2019-11-19T10:17:43.339Z] Accepted request OPTIONS /~/posts/rT7UgEMG8KhTlLOADE3y/comments --> posts
[2019-11-19T10:17:43.339Z] [worker-posts-3a43686e-d66c-4835-a45e-b4be49366232]: Assigning socketPath: /var/folders/zp/903b9f055r1czvjktw3fg_7r0000gn/T/firebase_emulator_invocation_3a43686e-d66c-4835-a45e-b4be49366232.sock
[2019-11-19T10:17:43.339Z] [worker-posts-3a43686e-d66c-4835-a45e-b4be49366232]: BUSY
[2019-11-19T10:17:43.339Z] [runtime-status] Trigger "posts" has been found, beginning invocation! {}
i  functions: Beginning execution of "posts"
[2019-11-19T10:17:43.340Z] [runtime-status]  {"httpsTrigger":{},"name":"posts","entryPoint":"posts"}
[2019-11-19T10:17:43.340Z] [runtime-status] Running posts in mode HTTPS {}
>  events.js:174
>        throw er; // Unhandled 'error' event
>        ^
>  
>  Error: listen EADDRINUSE: address already in use /var/folders/zp/903b9f055r1czvjktw3fg_7r0000gn/T/firebase_emulator_invocation_3a43686e-d66c-4835-a45e-b4be49366232.sock
>      at Server.setupListenHandle [as _listen2] (net.js:1263:19)
>      at listenInCluster (net.js:1328:12)
>      at Server.listen (net.js:1426:5)
>      at Function.listen (/Users/mmj/.npm-global/lib/node_modules/firebase-tools/node_modules/express/lib/application.js:618:24)
>      at Promise (/Users/mmj/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:563:46)
>      at new Promise (<anonymous>)
>      at /Users/mmj/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:528:15
>      at Generator.next (<anonymous>)
>      at /Users/mmj/.npm-global/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:7:71
>      at new Promise (<anonymous>)
>  Emitted 'error' event at:
>      at emitErrorNT (net.js:1307:8)
>      at process._tickCallback (internal/process/next_tick.js:63:19)
[2019-11-19T10:17:43.352Z] [worker-posts-3a43686e-d66c-4835-a45e-b4be49366232]: exited
[2019-11-19T10:17:43.353Z] [worker-posts-3a43686e-d66c-4835-a45e-b4be49366232]: FINISHED
@google-oss-bot
Copy link
Contributor

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

@samtstern
Copy link
Contributor

samtstern commented Nov 19, 2019 via email

@bkendall bkendall added the Needs: Author Feedback Issues awaiting author feedback label Nov 19, 2019
@samtstern samtstern self-assigned this Nov 19, 2019
@osadchiynikita
Copy link

+1 Same issue with latest version (7.8.0). Second call to the function throws this error.

Just rolled back to 7.7.0 and it works fine.

@samtstern
Copy link
Contributor

@osadchiynikita can you show me the simplest function you have that reproduces this error?

@osadchiynikita
Copy link

osadchiynikita commented Nov 19, 2019

@samtstern I just started to set up new project, so I was testing with the simple hello function

import { https } from 'firebase-functions';

export const hello = https.onRequest((request, response) => {
  response.send('Hello from Firebase!\n\n');
});

With the next firebase.json config

{
  "functions": {
    "source": ".",
    "predeploy": "npm run build"
  },
  "hosting": {
    "rewrites": [
      {
        "source": "**/**",
        "function": "hello"
      }
    ]
  },
  "emulators": {
    "functions": {
      "port": "4001"
    },
    "hosting": {
      "port": "4002"
    }
  }
}

When I'm calling function first time (open in browser), it executes correctly, but for the next call (page reload) server throws "Address in use" error

P.S. Thank you for the fast response

@samtstern
Copy link
Contributor

@osadchiynikita I was able to reproduce this, thank you for your help! Definitely downgrade to 7.7.0 for now.

@osadchiynikita
Copy link

@samtstern Great! Thank you

@samtstern
Copy link
Contributor

Ok it happened during this PR:
#1778

So it's my fault (obviously). Now need to dig.

@parsher
Copy link
Author

parsher commented Nov 20, 2019

@osadchiynikita @samtstern Thank you for all! I was worried about this, because I'm developing based on firebase.

@samtstern
Copy link
Contributor

samtstern commented Nov 20, 2019 via email

@richard-mckenna
Copy link

omg @parsher this was driving me nuts all yesterday, I was convinced it was something I was doing while configuring my Vue project to use the emulators in dev and live in production. Downgraded to 7.7.0 and it works fine. I didn't twig that I had updated firebase-tools yesterday morning, just before I started having issues. :| @samtstern I'll only blame you for an hour or so ha ha.

@samtstern
Copy link
Contributor

For everyone affected by this: version 7.8.1 was just released!

@parsher
Copy link
Author

parsher commented Nov 21, 2019

@samtstern Thank you for your fast release!
@richard-mckenna Me too, I eased every code I had written when I face it. ha ha. I am using Vue too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants