google-cloud-functions

Firebase Cloud Functions execution time is so fluctuate

六眼飞鱼酱① 提交于 2021-02-11 08:07:29
问题 I got this from google cloud console. I don't understand why after the function is executed, it should turn hot for some duration. However, after deploying the function and call it, I found cold start and then drop to actual and then increase to cold start again. Please help! // index.js import * as functions from 'firebase-functions' import express from 'express' import cors from 'cors' import auth from 'controllers/auth' const authApp = express() authApp.use(cors({ origin: true })) authApp

Firebase cloud function idempotency in docs

梦想的初衷 提交于 2021-02-10 20:24:25
问题 I'm following the docs for Firestore here on Aggregation Queries. I couldn't help but notice that the cloud function solution wouldn't exactly work since it's not idempotent: numRatings is incremented and avgRating recomputed each time. Though this example could be made idempotent if there was also a separate document being stored for each new rating: you'd add a check if the user has already submitted a rating for the restaurant. Is there something I'm missing that makes this example

Firebase cloud function idempotency in docs

亡梦爱人 提交于 2021-02-10 20:19:52
问题 I'm following the docs for Firestore here on Aggregation Queries. I couldn't help but notice that the cloud function solution wouldn't exactly work since it's not idempotent: numRatings is incremented and avgRating recomputed each time. Though this example could be made idempotent if there was also a separate document being stored for each new rating: you'd add a check if the user has already submitted a rating for the restaurant. Is there something I'm missing that makes this example

TypeError: this.path.replace is not a function at new FirestoreDelete

自闭症网瘾萝莉.ら 提交于 2021-02-10 18:27:45
问题 Trying to remove the users`s data calling a function from app. 'use strict'; const functions = require('firebase-functions'); const firebase_tools = require('firebase-tools'); const admin = require('firebase-admin'); const serviceAccount = require('./myapp.json'); admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: "https://myapp.firebaseio.com" }); let db = admin.firestore(); exports.mintAdminToken = functions.https.onCall((data, context) => { const uid =

Why does Google Cloud Function run a global function multiple times after deploy?

北城余情 提交于 2021-02-10 17:52:22
问题 I have set multiple triggers, like: exports.doSomething = functions.firestore.document('col/{doc}').onCreate(event => {}) Than I have a function that I want to run instant when I deployed. That looks something like this: now() function now(){ console.log("running function") } And I get this in my logs: Why does it run so many times and gets called by other functions? Full code, just tested it and running function gets called 4 times, the same amount as triggers I have set: const functions =

Firebase Cloud Functions bitly example throwing error

谁说胖子不能爱 提交于 2021-02-10 17:27:47
问题 I'm following the example from the github repository to short a link url https://github.com/firebase/functions-samples/tree/Node-8/url-shortener The error is giving is the following 12:49:56.472 a. m. shortenUrl Function execution took 509 ms, finished with status: 'error' 12:49:56.464 a. m. shortenUrl RequestError: Error: getaddrinfo EAI_AGAIN api-ssl.bitly.com:443 at new RequestError (/srv/node_modules/request-promise-core/lib/errors.js:14:15) at Request.plumbing.callback (/srv/node_modules

Google Cloud Authorized HTTP requests in Python

被刻印的时光 ゝ 提交于 2021-02-10 14:30:46
问题 I am trying to make an authorized request to a Google Cloud function from within Python using this code: import google.auth from google.auth.transport.urllib3 import AuthorizedHttp credentials, project = google.auth.default() authed_http = AuthorizedHttp(credentials) url = "MY_CLOUD_FUNCTON_URL" response = authed_http.request('POST', url) but I am getting the following error: google.auth.exceptions.RefreshError: ('invalid_scope: Invalid OAuth scope or ID token audience provided.', '{"error":

Google Cloud Authorized HTTP requests in Python

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 14:29:36
问题 I am trying to make an authorized request to a Google Cloud function from within Python using this code: import google.auth from google.auth.transport.urllib3 import AuthorizedHttp credentials, project = google.auth.default() authed_http = AuthorizedHttp(credentials) url = "MY_CLOUD_FUNCTON_URL" response = authed_http.request('POST', url) but I am getting the following error: google.auth.exceptions.RefreshError: ('invalid_scope: Invalid OAuth scope or ID token audience provided.', '{"error":

Google Cloud Functions crashes without an error message

孤者浪人 提交于 2021-02-10 14:20:59
问题 I'm running an http triggered cloud function. The script was tested under Flask conditions, and ran perfectly. For an unknown reason, the cloud running suddenly stops and I get "Error: could not handle the request". When I checked the function logs, there was no error message or any indication for a crash. All I see is an output printed by the program, down to the point where it stops I allocated the maximum memory size, 4GB, plus I reduced the size of data in my request (shorter time span,

How to call a synchronous sub function from a Cloud Function

无人久伴 提交于 2021-02-10 07:59:06
问题 I'd like to run all of my functions synchronously. But if I execute something like the code below the response is sent back before the return value is assigned. index.js exports.cfTest = (req, res) => { try { result = columnCount( 'project','dataset','table' ); console.log('sending response'); res.send('<OUTPUT>' + result + '</OUTPUT>'); } catch (err) { res.status(500).send('<ERROR>' + err + '</ERROR>'); } }; function columnCount(projectId, bqDataset, bqTable) { const BigQuery = require('