firebase-tools: `firebase serve` fails with TypeError on Travis CI

Hey there! I’m trying to run firebase serve on Travis CI to run smoke tests. App fails to start with Error: An unexpected error has occurred.:

i  functions: Preparing to emulate HTTPS functions. Support for other event types coming soon.
[2017-06-05T12:44:01.457Z] TypeError: Cannot read property 'refresh_token' of undefined
  • I’m using firebase serve --debug --only functions,hosting --token $FIREBASE_TOKEN --project $FIREBASE_PROJECT to run it
  • I also have sudo: required in Travis config
  • Everything works fine with same setup locally

Versions:

firebase-tools@3.9.1
firebase-functions@0.5.7
firebase@4.1.0

Any ideas?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 27 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Hi. I get the same error when I tried to run serve functions in a docker image.

Looks like the problem is the empty configstore. The auth does not set the token from the cli parameters because this line never executed: https://github.com/firebase/firebase-tools/blob/master/lib/auth.js#L230 (the currentRefreshToken === undefined and refreshToken equal with the --token parameter)

So when ensureDefaultCredentials read the tokens from the configstore it return with undefined

Having the same issue trying to use firebase serve --only functions --debug inside of a docker container for local development and testing, the initial HTTP calls for the token do respond with 200s.

functions_1           | i  functions: Preparing to emulate HTTPS functions. Support for other event types coming soon.
functions_1           | [2017-08-18T08:26:51.746Z] TypeError: Cannot read property 'refresh_token' of undefined
functions_1           |     at module.exports (/usr/local/share/.config/yarn/global/node_modules/firebase-tools/lib/ensureDefaultCredentials.js:31:45)
functions_1           |     at Object._startEmulator [as start] (/usr/local/share/.config/yarn/global/node_modules/firebase-tools/lib/serve/functions.js:91:3)
functions_1           |     at /usr/local/share/.config/yarn/global/node_modules/firebase-tools/lib/serve/index.js:16:19
functions_1           |     at arrayMap (/usr/local/share/.config/yarn/global/node_modules/lodash/lodash.js:660:23)
functions_1           |     at Function.map (/usr/local/share/.config/yarn/global/node_modules/lodash/lodash.js:9571:14)
functions_1           |     at _serve (/usr/local/share/.config/yarn/global/node_modules/firebase-tools/lib/serve/index.js:14:21)
functions_1           |     at Command._action (/usr/local/share/.config/yarn/global/node_modules/firebase-tools/commands/serve.js:42:12)
functions_1           |     at /usr/local/share/.config/yarn/global/node_modules/firebase-tools/lib/command.js:176:29
functions_1           |     at tryCatch (/usr/local/share/.config/yarn/global/node_modules/rsvp/dist/rsvp.js:525:12)
functions_1           |     at invokeCallback (/usr/local/share/.config/yarn/global/node_modules/rsvp/dist/rsvp.js:538:13)
functions_1           | 
functions_1           | Error: An unexpected error has occurred.
functions_1           | error Command failed with exit code 2.