cloud-functions-emulator icon indicating copy to clipboard operation
cloud-functions-emulator copied to clipboard

firebase serve unable to serve https function

Open hectorlee opened this issue 5 years ago • 3 comments

I was asked to file this bug here by the mods at the firebase-tools repo.

https://github.com/firebase/firebase-tools/issues/827#issuecomment-406106709

Version info

firebase v3.19.3 node v6.11.5 npm v3.10.10 nvm v0.33.2

firebase-admin 5.12.1 and firebase-functions 1.0.3 and 1.1.0

Platform Information

Mac OS 10.12.6

Steps to reproduce

firebase serve fails to emulate functions even with the example function in index.js.

const functions = require('firebase-functions');

// Create and Deploy Your First Cloud Functions
// https://firebase.google.com/docs/functions/write-firebase-functions

exports.helloWorld = functions.https.onRequest((request, response) => {
 response.send("Hello from Firebase!");
});

Expected behavior

Expected to serve functions.

Actual behavior

➜  functionsTest firebase serve --only functions --debug
[2018-07-13T05:31:30.253Z] ----------------------------------------------------------------------
[2018-07-13T05:31:30.257Z] Command:       /Users/hectorlee/.nvm/versions/node/v6.11.5/bin/node /Users/hectorlee/.nvm/versions/node/v6.11.5/bin/firebase serve --only functions --debug
[2018-07-13T05:31:30.258Z] CLI Version:   3.19.3
[2018-07-13T05:31:30.258Z] Platform:      darwin
[2018-07-13T05:31:30.258Z] Node Version:  v6.11.5
[2018-07-13T05:31:30.258Z] Time:          Fri Jul 13 2018 13:31:30 GMT+0800 (+08)
[2018-07-13T05:31:30.259Z] ----------------------------------------------------------------------

[2018-07-13T05:31:30.268Z] > 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-07-13T05:31:30.268Z] > authorizing via signed-in user
[2018-07-13T05:31:30.272Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/firecast-caaa6

 Fri Jul 13 2018 13:31:30 GMT+0800 (+08)
[2018-07-13T05:31:31.132Z] <<< HTTP RESPONSE 200 server=nginx, date=Fri, 13 Jul 2018 05:31:31 GMT, content-type=application/json; charset=utf-8, content-length=111, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-07-13T05:31:31.133Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/firecast-caaa6/tokens

 Fri Jul 13 2018 13:31:31 GMT+0800 (+08)
[2018-07-13T05:31:31.887Z] <<< HTTP RESPONSE 200 server=nginx, date=Fri, 13 Jul 2018 05:31:31 GMT, content-type=application/json; charset=utf-8, content-length=263, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-07-13T05:31:31.888Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/firecast-caaa6

 Fri Jul 13 2018 13:31:31 GMT+0800 (+08)
[2018-07-13T05:31:33.071Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 13 Jul 2018 05:31:33 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="43,42,41,39,35", accept-ranges=none, connection=close

=== Serving from '/Users/hectorlee/code/functionsTest'...

i  functions: Preparing to emulate functions.
[2018-07-13T05:31:33.531Z] Fetching environment
[2018-07-13T05:31:33.533Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/11896845545:getServerAppConfig

 Fri Jul 13 2018 13:31:33 GMT+0800 (+08)
[2018-07-13T05:31:34.187Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Fri, 13 Jul 2018 05:31:34 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="43,42,41,39,35", accept-ranges=none, connection=close
[2018-07-13T05:31:34.188Z] Starting @google-cloud/functions-emulator
[2018-07-13T05:31:34.209Z] Parsing function triggers
[2018-07-13T05:31:34.341Z] Error while deploying to emulator: TypeError: Cannot read property 'call' of undefined
TypeError: Cannot read property 'call' of undefined
    at Promise (/Users/hectorlee/.nvm/versions/node/v6.11.5/lib/node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator/src/client/rest-client.js:34:42)
    at getService.then (/Users/hectorlee/.nvm/versions/node/v6.11.5/lib/node_modules/firebase-tools/node_modules/@google-cloud/functions-emulator/src/client/rest-client.js:33:16)
    at process._tickDomainCallback (internal/process/next_tick.js:135:7)
⚠  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.

hectorlee avatar Jul 24 '18 04:07 hectorlee

I can't seem to get any functions to emulate using new firebase-tools, firebase-functions, and firebase-admin. Even firebase-samples default examples fail, so do my previously working functions.

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

After 2 days of searching, I still find conflicting info on the status of what versions to use and I can no longer get a simple helloworld app to emulate: Docs say (https://firebase.google.com/docs/functions/manage-functions#set_nodejs_version) you can specify either node 6 or node 8 runtime. Great. I have installed 8. But errors now arise from the emulator which say: Warning: You're using Node.js v8.11.3 but Google Cloud Functions only supports v6.11.5. I figured if I use the recommended Typescript to get all the async/await/es6 goodness shown in these training videos (https://firebase.google.com/docs/functions/video-series/) that it should transpile to es5, which I'd hope would overcome the need for an older node runtime environment. Apparently not the case despite these tutorial videos show he's running node 10 and deploying functions and encouraging us to emulate the functions before deployment. Do his function emulations actually work? If so, what am I doing wrong?

So if I understand, I can use node 8 runtime, but can't use node 8 when emulating functions yet, even when I try a simple helloWorld straight from the firebase examples?

So I guess I have to uninstall all node 8 from my system and go back to 6.11.5? Even though when I install firebase-tools it throws a warning that I need to update to the latest firebase-tools, firebase-functions and firebase-admin? Which of course, starts this whole process over again? When I run npm install in the functions dir of default stock examples it wants me to update to "firebase-admin": "^5.13.1", "firebase-functions": "^2.0.2" which I do, but still emulation doesn't work.

I must have lucked out on my previous app, which went smoothly and had me praising FB. Strangely, I was on Node 8 then and didn't even specify "engines: "8" on that one. It just worked. I'm not an advanced Node or Firebase developer, in fact, trying hard to grok all of it, but this is crazy making right now. Is this all due to the latest updates (which came right in the middle of my current project and broke everything)?

Can someone specify exact versions of node, firebase, firebase-tools, firebase-functions, and firebase-admin I should use to get something done? Do I need firebase SDK too (I think it's not necessary without auth, etc. correct?)

Thanks in advance, J

$ node --version v8.11.3 $ npm --version 6.2.0

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

Warning: You're using Node.js v8.11.3 but Google Cloud Functions only supports v6.11.5.

[2018-07-28T18:54:08.421Z] ---------------------------------------------------------------------- [2018-07-28T18:54:08.424Z] Command: /usr/local/bin/node /usr/local/bin/firebase serve --debug [2018-07-28T18:54:08.424Z] CLI Version: 4.0.0 [2018-07-28T18:54:08.424Z] Platform: darwin [2018-07-28T18:54:08.424Z] Node Version: v8.11.3 [2018-07-28T18:54:08.425Z] Time: Sat Jul 28 2018 11:54:08 GMT-0700 (PDT) [2018-07-28T18:54:08.425Z] ----------------------------------------------------------------------

archebyte avatar Jul 28 '18 19:07 archebyte

Ping?

ctrlaltdev avatar Oct 26 '18 23:10 ctrlaltdev

Any updates?

bluet avatar Apr 17 '19 04:04 bluet