Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

ERROR: TypeError: google.discoverAPI is not a function on functions start #321

Open
davidwallen opened this issue Mar 25, 2019 · 31 comments

Comments

@davidwallen
Copy link

Host: Pixelbook Slate i7 16 GB
Host OS: Google Chrome OS Version 72.0.3626.122 (Official Build) (64-bit)
Container OS: Linux penguin 4.19.4-02480-gd44d301822f0 #1 SMP PREEMPT Thu Dec 6 17:45:27 PST 2018 x86_64 GNU/Linux
Virtual machine info:

  • memory: 10GiB System memory
  • processor: 06/8e

node --version: v8.15.1
npm --version: 6.4.1
functions --version: 1.0.0-beta.5
reproduced by: user:~/cloud-functions-emulator$ functions start
output:

Google Cloud Functions Emulator RUNNING
ERROR: TypeError: google.discoverAPI is not a function
    at Promise (/home/davidwallen/cloud-functions-emulator/src/client/rest-client.js:112:14)
    at new Promise (<anonymous>)
    at RestClient.getService (/home/davidwallen/cloud-functions-emulator/src/client/rest-client.js:104:12)
    at RestClient._action (/home/davidwallen/cloud-functions-emulator/src/client/rest-client.js:31:17)
    at RestClient.listFunctions (/home/davidwallen/cloud-functions-emulator/src/client/rest-client.js:145:17)
    at Controller.list (/home/davidwallen/cloud-functions-emulator/src/cli/controller.js:521:24)
    at controller.doIfRunning.then (/home/davidwallen/cloud-functions-emulator/src/cli/commands/list.js:72:28)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
@bluet
Copy link

bluet commented Apr 17, 2019

I'm having exact the same problem after a nvm and node upgrading and reinstalled firebase-tools.

@davidwallen have you solved it?

@kmcnellis
Copy link

I had the same earlier today. I solved it by some combination of reinstalling the gcloud sdk, upgrading node, and accepting a pop-up from Mac granting network access to Node (they happened at approximately the same time, so I wasn’t able to narrow it down)

@laiso
Copy link

laiso commented Apr 17, 2019

1.0.0-beta.6.0 released before couple hours ago. after that could not deploy a function to my local project.
https://www.npmjs.com/package/@google-cloud/functions-emulator/v/1.0.0-beta.6.0

In workaround I've fixed the issue can not launch functions-emulaor from firebase-tools as bellow:

npx functions stop
rm -rf ./node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator
npm i "@google-cloud/functions-emulator"@"1.0.0-beta.5
npx firebase functions:shell

@roynes
Copy link

roynes commented Apr 17, 2019

thanks @laiso, I hope google finds a way to solve this

@rschpdr
Copy link

rschpdr commented Apr 17, 2019

@laiso pointed me to the right direction but in my case I had to downgrade a version lower than him. Downgraded to @google-cloud/functions-emulator"@1.0.0-beta.4 and after solving another, unrelated error, it worked.

If you downgrade to beta.4 and encounter the "RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. " error, I got it to work applying this hack: Issue #770

@clementdevos
Copy link

@laiso recommendation fixed it for me too, but i had to run it in my global npm repository ! :)

@grant
Copy link
Contributor

grant commented Apr 17, 2019

OK. I was able to reproduce this error by following the quickstart in the README.md. I'm not sure of the issue, but I'm guessing there's a problem with the Google API Client dependency.

https://github.com/GoogleCloudPlatform/cloud-functions-emulator/blob/6dbd88345f6f7d129644d2547d949aaf36897fd0/src/client/rest-client.js#L112

@HugoGresse
Copy link

Was using [email protected] but got the same issue with older verions
solved this using:

  1. NODEV="$(node -v)" && rm -rf ~/.nvm/versions/node/$NODEV/lib/node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator
  2. npm i -g @google-cloud/[email protected]
  3. NODEV="$(node -v)" && cp -R ~/.nvm/versions/node/$NODEV/lib/node_modules/@google-cloud/functions-emulator ~/.nvm/versions/node/$NODEV/lib/node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator

@grant
Copy link
Contributor

grant commented Apr 17, 2019

1.0.0-beta.6 has been unpublished.
Can you try installing the Firebase CLI an trying again for that issue?

Note that this issue still exists with this GitHub repo.

@bluet
Copy link

bluet commented Apr 17, 2019

@grant I can confirm it works now.

[2019-04-17T19:22:54.820Z] ----------------------------------------------------------------------
[2019-04-17T19:22:54.824Z] Command:       /home/bluet/.nvm/versions/node/v10.15.0/bin/node /home/bluet/.nvm/versions/node/v10.15.0/bin/firebase serve --debug
[2019-04-17T19:22:54.825Z] CLI Version:   6.6.0
[2019-04-17T19:22:54.825Z] Platform:      linux
[2019-04-17T19:22:54.825Z] Node Version:  v10.15.0
[2019-04-17T19:22:54.825Z] Time:          Thu Apr 18 2019 03:22:54 GMT+0800 (GMT+08:00)
[2019-04-17T19:22:54.826Z] ----------------------------------------------------------------------

Though not sure why it stuck at Parsing function triggers for several minutes every time I run firebase server --debug command. This didn't happen utill yesterday I did npm upgrade.

@LVeach
Copy link

LVeach commented Apr 17, 2019

[2019-04-17T20:11:10.027Z] ----------------------------------------------------------------------
[2019-04-17T20:11:10.043Z] Command: C:\Program Files\nodejs\node.exe C:\Users\Luke\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js functions:shell --debug
[2019-04-17T20:11:10.043Z] CLI Version: 6.6.0
[2019-04-17T20:11:10.043Z] Platform: win32
[2019-04-17T20:11:10.043Z] Node Version: v8.11.2
[2019-04-17T20:11:10.043Z] Time: Wed Apr 17 2019 13:11:10 GMT-0700 (Pacific Daylight Time)
[2019-04-17T20:11:10.043Z] ----------------------------------------------------------------------
.. ..
[2019-04-17T20:11:14.378Z] Error while deploying to emulator: TypeError: google.discoverAPI is not a function
TypeError: google.discoverAPI is not a function

@bluet
Copy link

bluet commented Apr 17, 2019

@LVeach did you uninstall and install firebase-tools again in the past 2 hours? If not, please try it, as @grant mentioned in #321 (comment) that he unpublished the latest (beta 6, w/ bug) version so you'll have the stable one back now.

@LVeach
Copy link

LVeach commented Apr 17, 2019

@bluet I thought I had, but I will attempt those steps again!

@bluet
Copy link

bluet commented Apr 17, 2019

@LVeach if you still have the same issue, please paste your steps and the output of functions start debug info, so they can help you further. :-)

@LVeach
Copy link

LVeach commented Apr 17, 2019

@bluet Absolutely, I am currently doing a clean install and then will re-apply the steps above and see where it's at

@LVeach
Copy link

LVeach commented Apr 17, 2019

@bluet @grant :
blowing away my global yarn cache along with the above steps got me back in business, thank you very much for the pointers in this thread!

@gregtap
Copy link

gregtap commented Apr 19, 2019

Same issue with latest commit.

On one side we need node 8 to get async/await in our functions code and on the other we cant use node 8 on GoogleCloudPlatform/cloud-functions-emulator.

@bluet
Copy link

bluet commented Apr 19, 2019

@coulix My projects use node 8 and node 10 in local test environments and they work fine, so don't worry. 😃

At the time you post comment, the latest commit is 098e253, which is before the problem get solved.
As mentioned in #321 (comment) , DON'T use latest commit on github. Instead, please use npm to install it.
And as mentioned in #321 (comment) , please uninstall and reinstall.

@gregtap
Copy link

gregtap commented Apr 19, 2019

@bluet I am trying

nvm current
v8.16.0

npx functions --version
1.0.0-beta.5

I used yarn install git://github.com/GoogleCloudPlatform/cloud-functions-emulator.git


i  functions: Preparing to emulate functions.
i  hosting: Serving hosting files from: prod/client
✔  hosting: Local server: http://localhost:3000
⚠  functions: Failed to emulate nuxtssr
⚠  functions: Failed to emulate func
i  functions: No HTTPS functions found. Use firebase functions:shell if you would like to emulate other types of functions.
^CShutting down...

 ~/code/perso/nuxt2-ssr-firebase   feature/test ● ?  npx functions start                              SIGINT(2) ↵  10032  21:27:04
Google Cloud Functions Emulator RUNNING
ERROR: TypeError: google.discoverAPI is not a function
    at Promise (/Users/greg/code/perso/nuxt2-ssr-firebase/node_modules/@google-cloud/functions-emulator/src/client/rest-client.js:112:14)
    at new Promise (<anonymous>)
    at RestClient.getService (/Users/greg/code/perso/nuxt2-ssr-firebase/node_modules/@google-cloud/functions-emulator/src/client/rest-client.js:104:12)
    at RestClient._action (/Users/greg/code/perso/nuxt2-ssr-firebase/node_modules/@google-cloud/functions-emulator/src/client/rest-client.js:31:17)
    at RestClient.listFunctions (/Users/greg/code/perso/nuxt2-ssr-firebase/node_modules/@google-cloud/functions-emulator/src/client/rest-client.js:145:17)
    at Controller.list (/Users/greg/code/perso/nuxt2-ssr-firebase/node_modules/@google-cloud/functions-emulator/src/cli/controller.js:521:24)
    at controller.doIfRunning.then (/Users/greg/code/perso/nuxt2-ssr-firebase/node_modules/@google-cloud/functions-emulator/src/cli/commands/list.js:72:28)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)````

1 similar comment
@gregtap

This comment has been minimized.

@bluet
Copy link

bluet commented Apr 20, 2019

@coulix did you try npm i @google-cloud/[email protected] ?
AFAIK, and as replied in #321 (comment) and other comments listed in that comment, DON'T install from this git repo directly until @grant has further fixes.

@grant I noticed that 1.0.0-beta.6 is listing on npm again since a day ago, but I can't see any fix. Did you intend to publish the same buggy version or by mistake?

@grant
Copy link
Contributor

grant commented Apr 20, 2019

The beta 6 update just removes the Node 6 warning so the Firebase CLI won't show the warning either. This was a request by the Firebase CLI team.

@gregtap
Copy link

gregtap commented Apr 21, 2019

Ok I did functions stop, uninstall then installed the pinned beta.5 branch.
I am making progress.


i  functions: Preparing to emulate functions.
i  hosting: Serving hosting files from: prod/client
✔  hosting: Local server: http://localhost:3000
⚠  functions: Failed to emulate nuxtssr
⚠  functions: Failed to emulate func
error: {
    code: 404,
    status: "NOT_FOUND",
    message: "Function nuxtssr in location us-central1 in project nuxt-test-96b4a does not exist",
    errors: [
        "Function nuxtssr in location us-central1 in project nuxt-test-96b4a does not exist"
    ]
  }
}

@bluet
Copy link

bluet commented Apr 22, 2019

@coulix can you provide a demo repo to reproduce your issue? I think that would help people on investigating where the problem is.

@gregtap
Copy link

gregtap commented Apr 22, 2019

I have it here https://github.com/coulix/nuxt2-ssr-firebase

yarn setup
yarn serve

https://nuxt-test-96b4a.firebaseapp.com/

Renderer is loaded but not all resources are unavailable! Please check /srv/nuxt/dist/server existence.

nuxt/nuxt#5549

@bluet
Copy link

bluet commented Apr 23, 2019

@coulix I've checked the repo you provide and followed your steps, it installed 1.0.0-beta.6.

You can check it by $ cat node_modules/@google-cloud/functions-emulator/package.json |grep version which shows "version": "1.0.0-beta.6",.

The reason is, you specified version ^1.0.0-beta.5, which the ^ will install latest compatible version of @google-cloud/functions-emulator.

  "dependencies": {
    "@google-cloud/functions-emulator": "^1.0.0-beta.5"
  }

And due to @grant published broken version 1.0.0-beta.6 again (mentioned in #321 (comment) and #321 (comment)), you will get the broken 1.0.0-beta.6 installed in your system.


After npm i @google-cloud/[email protected] and those setup processes, I can get it running.

bluet@Zorya:~/workspace/tmp/nuxt2-ssr-firebase$ NODE_ENV=development firebase serve   --only functions,hosting -p 3000 --project test-cf2e8

=== Serving from '/home/bluet/workspace/tmp/nuxt2-ssr-firebase'...

i  functions: Preparing to emulate functions.
Warning: You're using Node.js v10.15.3 but Google Cloud Functions only supports v6.11.5.
i  hosting: Serving hosting files from: prod/client
✔  hosting: Local server: http://localhost:3000
✔  functions: nuxtssr: http://localhost:3001/test-cf2e8/us-central1/nuxtssr
✔  functions: func: http://localhost:3001/test-cf2e8/us-central1/func

And these messages showed when requesting http://localhost:3000/ doesn't belong to cloud-functions-emulator. You should check your nuxt2 project itself.

[hosting] Rewriting / to local function nuxtssr
info: User function triggered, starting execution
info: IN New Nuxt Trial: 
error: 
03:13:59  ERROR  Renderer is loaded but not all resources are unavailable! Please check /home/bluet/workspace/tmp/nuxt2-ssr-firebase/prod/server/nuxt/dist/server existence.

  at VueRenderer.renderRoute (node_modules/@nuxt/vue-renderer/dist/vue-renderer.js:2817:19)
  at Server.renderRoute (node_modules/@nuxt/server/dist/server.js:811:38)
  at nuxtMiddleware (node_modules/@nuxt/server/dist/server.js:124:26)
  at call (node_modules/connect/index.js:239:7)
  at next (node_modules/connect/index.js:183:5)
  at servePlaceholderMiddleware (node_modules/serve-placeholder/src/index.js:29:16)
  at call (node_modules/connect/index.js:239:7)
  at next (node_modules/connect/index.js:183:5)
  at next (node_modules/connect/index.js:161:14)
  at node_modules/@nuxt/server/dist/server.js:555:5

info: Execution took 23 ms, user function completed successfully
127.0.0.1 - - [23/Apr/2019:19:13:59 +0000] "GET / HTTP/1.1" 500 - "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/73.0.3683.86 Chrome/73.0.3683.86 Safari/537.36"

Because I didn't see anything in that folder.

$ LC_ALL=C ls /home/bluet/workspace/tmp/nuxt2-ssr-firebase/prod/server/nuxt/dist/server
ls: cannot access '/home/bluet/workspace/tmp/nuxt2-ssr-firebase/prod/server/nuxt/dist/server': No such file or directory

@bluet
Copy link

bluet commented Apr 23, 2019

I just realized that what mentioned in #321 (comment) is that the new beta.6 doesn't break things. So it's ok to have beta.6 installed. Sorry for misunderstanding you @grant

@coulix I've tested your repo and it seems to be problems with your nuxt project itself.

@gregtap
Copy link

gregtap commented Apr 24, 2019

@bluet Thank you so much for the investigation! I will pursue this bug onto Nuxt then.

@JFGHT
Copy link

JFGHT commented Apr 25, 2019

I'm using beta 6 and have the same error by running yarn serve, which is a composition of npm run build && firebase serve --only functions.

Running those 2 commands separately works.

@alex89607
Copy link

alex89607 commented Apr 26, 2019

Hi! I try to debug firestore functions locally and get the same error. (use nvm, windows 10 and example functions "makeUppercase").

`firebase --debug functions:shell
[2019-04-26T08:41:30.933Z] ----------------------------------------------------------------------
[2019-04-26T08:41:30.937Z] Command: C:\Program Files\nodejsnvm\node.exe C:\Users\briza\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js --debug functions:shell
[2019-04-26T08:41:30.938Z] CLI Version: 6.6.0
[2019-04-26T08:41:30.938Z] Platform: win32
[2019-04-26T08:41:30.938Z] Node Version: v8.16.0
[2019-04-26T08:41:30.939Z] Time: Fri Apr 26 2019 11:41:30 GMT+0300 (Russia TZ 2 Standard Time)
[2019-04-26T08:41:30.939Z] ----------------------------------------------------------------------

[2019-04-26T08:41:30.950Z] > 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"]
[2019-04-26T08:41:30.951Z] > authorizing via signed-in user
...
[2019-04-26T08:41:34.891Z] Starting @google-cloud/functions-emulator
[2019-04-26T08:41:34.936Z] Parsing function triggers
[2019-04-26T08:41:35.279Z] Deploying functions locally
[2019-04-26T08:41:35.287Z] Error while deploying to emulator: TypeError: google.discoverAPI is not a function
TypeError: google.discoverAPI is not a function
at Promise (C:\Users\briza\AppData\Roaming\npm\node_modules\firebase-tools\node_modules@google-cloud\functions-emulator\src\client\rest-client.js:112:14)
at new Promise ()
at RestClient.getService (C:\Users\briza\AppData\Roaming\npm\node_modules\firebase-tools\node_modules@google-cloud\functions-emulator\src\client\rest-client.js:104:12)
at RestClient._action (C:\Users\briza\AppData\Roaming\npm\node_modules\firebase-tools\node_modules@google-cloud\functions-emulator\src\client\rest-client.js:31:17)
at RestClient.getFunction (C:\Users\briza\AppData\Roaming\npm\node_modules\firebase-tools\node_modules@google-cloud\functions-emulator\src\client\rest-client.js:132:17)
at Controller.deploy (C:\Users\briza\AppData\Roaming\npm\node_modules\firebase-tools\node_modules@google-cloud\functions-emulator\src\cli\controller.js:389:24)
at C:\Users\briza\AppData\Roaming\npm\node_modules\firebase-tools\lib\functionsEmulator.js:153:18
at arrayMap (C:\Users\briza\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\lodash\lodash.js:639:23)
at Function.map (C:\Users\briza\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\lodash\lodash.js:9556:14)
at C:\Users\briza\AppData\Roaming\npm\node_modules\firebase-tools\lib\functionsEmulator.js:131:26
! functions: Failed to emulate makeUppercase
i functions: No functions to emulate.
No functions emulated.`

@bluet
Copy link

bluet commented Apr 28, 2019

@alex89607 seems like you're not using the latest beta.6 but the previous beta.6.

Please try to clean your package caches and install from npmjs again.

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

No branches or pull requests