Questions tagged [google-cloud-functions]

0

votes
0

answer
4

Views

Get number of documents in a big collection in Cloud Firestore

I know this question was already asked but I'm being specific about my case: I've got a large database (approximately 1 million documents inside the collection users). I wanna get the exact number of documents inside users. I'm trying this: export const count_users = functions.https.onRequest((reque...
Daniel
1

votes
1

answer
464

Views

Does Cloud Functions for Firebase support file operation? [duplicate]

This question already has an answer here: Write temporary files from Google Cloud Function 1 answer I am developing a mobile app and it is using Firebase as the backend. I want to compress some files immediately after they are uploaded to the Cloud Storage using Cloud Functions. So I need to writ...
Sasa Simovic
1

votes
2

answer
589

Views

How to handle backpressure using google cloud functions

Using google cloud functions, is there a way to manage execution concurrency the way AWS Lambda is doing? (https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html) My intent is to design a function that consumes a file of tasks and publish those tasks to a work queue (pub/sub). I wan...
simon
0

votes
0

answer
4

Views

Custom https endpoint for alexa - didn't get expected request from alexa

I am trying to make a custom endpoint(https) for alexa using firebase. Here is my index.js code exports.alexaSkill = functions.https.onRequest((request, response) => { console.log('REQUEST:'); console.log(request); console.log('RESPONSE:'); console.log(response); return response.status(200).json({...
Anshul Singh
1

votes
1

answer
305

Views

accessing doc.id in .onWrite firebase cloud function

I'm triggering a cloud function with onWrite. Within the onWrite function, I want to do something with the ref ID of the document that was written. How can I grab this? My current code looks something like this, but I don't know how to fill eventID. exports.syncEvents = functions.firestore .document...
T_R_U_T_H
1

votes
1

answer
163

Views

Detected an object of type “Timestamp” that doesn't match the expected instance

I'm wondering why is the Timestamp object is not working as I expect? It works in test environment (I use Mocha), but throws error when it has been deployed. index.ts import { Timestamp, QuerySnapshot } from '@google-cloud/firestore'; .... async someFunction() { let col = firestore.collection('myco...
Yosi Pramajaya
1

votes
3

answer
457

Views

Each then() should return a value or throw Firebase cloud functions

I am writing a cloud function for firebase using javascript but I am stuck, I don't know the exact meaning of error and unable to solve it.. The error states: 27:65 error Each then() should return a value or throw promise/always-return 'use strict' const functions = require('firebase-functions'...
Ikram Khan Niazi
1

votes
1

answer
39

Views

How to control usage data of firebase with Blaze price

When I make chatbot by Dialogflow with firebase blaze price, If some black-user use macro with my chatbot as sending a ton of message, I have to pay all about that request? How can I control about this? I have to check usage data on real time?
DD DD
1

votes
1

answer
25

Views

Firebase cloud functions - what happens with multiple HTTP triggers at once

I have a firebase cloud function that is an endpoint for an external API, and it handles a POST request. This external API POSTS data to my cloud function endpoint at random intervals (this cloud function gets pinged with a POST request based on when a result is returned from this external API, and...
user3869231
7

votes
1

answer
129

Views

Firebase cloud function returns 304 error and then restarts

I've been stuck on this for months. I have removed some minor details from the function but nothing major. I have this https cloud function that ends a session and then uses endTime and startTime to calculate bill which is then returned to the client. startTime is retrived from the realtime firebase...
1

votes
2

answer
26

Views

update firestore document with cloud functions

hello im trying to update document in firestore with cloud functions but im confused on how cloud functions know which document to update here is my code cloud functions code exports.newsletterGreetConfirm = functions.firestore .document('newsletter/{newsletterId}') .onUpdate((change, context) => {...
hello world
0

votes
1

answer
9

Views

How can I customize the deployment bucket name for Google Cloud via the Serverless Framework?

Is there a way to use a predefined bucket using serverless and gcp? I tried using: deploymentBucket: name: build-artifacts-kkesley ...but it ignores it and create it's own bucket.
kkesley
1

votes
0

answer
26

Views

CORS clashing with promise being returned

I have a function that i need to return a list of users after calling an API (firebase function). I am using express CORS on the server to allow requests from local host. The issue I am having is that the CORS preflight is returning a 204 with no response before my data (which I know is expected fo...
Eden WebStudio
1

votes
2

answer
85

Views

How to send unique registration links with firebase?

I want to build an application where users just can register with 'Invitation'. Users already with account can send invitations to the specified e-mail addresses, then the app send an e-mail with a link to the registration where there's a token and just the specified e-mail address can be used. So...
Gergő Horváth
0

votes
0

answer
6

Views

Erratic Google Cloud Function when running a shell script

I am trying to run a shell script on a Google Cloud Function. I am using Node as the framework, and have tried different ways to run the script: execSync, execFileSync, spawnSync, etc: try { const output = require('child_process').execSync(__dirname + '/run.sh', [], { stdio: 'inherit', shell: '/bin...
Vic Seedoubleyew
1

votes
2

answer
876

Views

How to write to a cloud storage bucket with a firebase cloud function triggered from firestore?

To make sure this is as clean and isolated as possible, I created a new test project with nothing in it other than these steps. I then enabled cloud firestore in the console. I created a new collection called 'blarg' (great name, eh!). I added a document to it, and used the auto-id, then added a fi...
xrd
0

votes
0

answer
3

Views

Dialogflow doesn't perform web requests

I wrote a little js file that returns departure of public transport. This is what I expect: const dvb = require('dvbjs'); dvb.findStop('NUP').then((data) => { console.log( 'Abfahrten für '+data[0].name+ ' in ' +data[0].city+':' ); dvb.monitor(data[0].id, 0, 1).then((data) => { for (const bus of dat...
1

votes
2

answer
99

Views

How should I replicate Firebase Queue data properties in Cloud Functions for Firebase?

Firebase Queue uses the following properties to track processing: _state _state_changed _owner _progress _error_details _id I am migrating some of my Firebase Queue code to Cloud Functions for firebase. How would I obtain an equivalent data property for the _owner property? Alternatively, considerin...
Lindauson
1

votes
1

answer
302

Views

Reference a pem file in a cloud function

I am trying to convert a firebase-queue worker to send push notification to a cloud function. I am using node-apn to send push notification to iOS devices. It requires setting up a connection which requires me to specify a key.pem file and cert.pem file. These files are present at the same location...
Varun Gupta
1

votes
1

answer
711

Views

Firebase Functions cors

I am using Firebase Functions and everything worked as intended when using the Ionic Native HTTP plugin (https://ionicframework.com/docs/native/http/). Today, I decided to move towards the Angular-Http implementation, since I can test my code in the browser then too. The issue I am facing is, since...
Thomas
1

votes
1

answer
776

Views

UnityWebRequest HTTP POST to Cloud Functions for Firebase

I'm Having some trouble making an POST Http Request to my firebase cloud-functions project from Unity3D game engine. I keep getting a code 400 response, and in the firebase console I can see the following error: Error: invalid json at parse I don't really have a lot of knowledge about Http requests...
Carles
1

votes
1

answer
265

Views

Unable to send FCM Message using Cloud Functions for Firebase

I am trying to send a basic use-case of sending FCM message using Cloud Functions for Firebase. The function is timing out and the message never got send. Here is the function. exports.sendNotification = functions.https.onRequest((req, res) => { const keyword = req.query.keyword; const username = r...
Val Okafor
1

votes
1

answer
542

Views

Firebase Cloud Function config to access other project db

I need to create a Cloud Function that will access the Firebase DB that is running in another project. If it was accessing the db in the current project, I could use code such as const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.c...
Prisoner
1

votes
1

answer
1k

Views

ValueProvider Issue

I am trying to get the value of a property that is passed from a cloud function to a dataflow template. I am getting errors because the value being passed is a wrapper, and using the .get() method fails during the compile. with this error An exception occurred while executing the Java class. null:...
Vlad
1

votes
1

answer
514

Views

Update Firebase database on Storage change using Firebase Functions

I am trying to implement the Profile Picture feature in my Android app. So I have used Generate Thumbnail sample from firebase. So whenever I am uploading an full sized image, it generates and thumbnail for me. But I want to update the URL of thumbnail in my realtime database once the thumbnail is g...
Chandra Sekhar
1

votes
1

answer
1.1k

Views

How to invoke Cloud Functions from Firebase Hosting?

I have static content on firebase-hosting - where i have routing eg. ~/xxx - is possible to invoke firebase-function when someone enter this path ?
marcin
1

votes
1

answer
383

Views

Firebase cloud functions - observe ref

I´m completely new to firebase cloud functions. I want to refer to different refs inside a cloud function and get an array with the values of these. So for example I want to get all the fruits from ('fruits'). similar to (IOS): ref.observe(.childAdded ... ) How do I code that?
ktm125
1

votes
2

answer
1.6k

Views

Cloud Functions for Firebase for uploading image and resizing to new width

I would like to leverage Cloud Functions for Firebase to resize an image on upload and overwrite the original so there is only one image per upload. Also, rather than create an image with a specified width and height, I would like ImageMagick to resize based on a given width, such as 800px. I've lo...
Playgraph
1

votes
1

answer
775

Views

Google Cloud Functions CPU Speed Setup

I was not able to find settings for GCF to setup CPU speed. In pricing calculator there is several options for GCF environment on which it running, and by default as I understand the least performant option is used (800MHz?). So, I wounder, is there any options in Cloud Console or during Functions d...
1

votes
1

answer
1.5k

Views

Cloud Functions for Firebase HTTP Request

I want to send an HTTP Request from Android to a cloud function, post some values, then input these values into real time database. index.js const functions = require('firebase-functions'); exports.testPost = functions.https.onRequest((req, res) => { console.log(req.body); }); How can I accomplish t...
Qandeel Haider
1

votes
1

answer
190

Views

Cloud Functions for Firebase to index Firebase Database Objects in Algolia

I went through docs, github repositories but nothing worked for me yet. My datastructure: App { posts : { : { auth_name : 'name', text : 'some text' //and many other fields } } } 1) Github repository : If I use this, I only get one field from one function, if I need all the fields, I would need to w...
Bugs Buggy
1

votes
1

answer
395

Views

Cloud Functions for Firebase: functions.pubsub.topic('testTopic').onPublish not called

I've copied this code snippet from the official documentation of cloud functions: exports.helloPubSub = functions.pubsub.topic('testTopic').onPublish(event => { return console.log('test topic event data', event.data) }) The topic exists, the function is deployed successfully; if I send a message to...
anitteb
1

votes
2

answer
238

Views

Google Cloud Functions with Trace Agent connection

I need to connect monitoring and tracing tools for our application. Our main code is on Express 4 running on Google Cloud Functions. All requests incoming from front nginx proxy server that handle domain and pretty routes names. Unfortunately, trace agent traces this requests, that coming on nginx f...
1

votes
1

answer
509

Views

Node doesn't get removed from Firebase Database?

I have the following data structure: Unfortunately, 'days' does not get removed from the database with the code below. My current code: const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.deleteOldItems =...
1

votes
2

answer
657

Views

Notifications not appearing in background state and killed state of an app

I'm trying to push notifications to the end-users of the app when post is uploaded. It works fine when the app is in foreground but doesn't show up when then the app is in background or killed. Is there any way to show the notifications when the app is killed or running in the background. Here is th...
evana priya
1

votes
1

answer
420

Views

How can I keep objects stored in firebase cloud function RAM?

My application needs to build a couple of large hashmaps before processing a user's request. Ideally I want to store these hashmaps in-memory on the machine, which means it never has to do any expensive processing and can process any incoming requests quickly. But this doesn't work for firebase bec...
pete
1

votes
1

answer
424

Views

Check if name exists using Cloud Functions for Firebase

How do I check if a name exists using Cloud Functions for Firebase? I have the following data structure: And this pseudo-code: exports.addIt = functions.database.ref('/messages/{pushId}') .onWrite(event => { if(creationDate does not exist) event.data.adminRef.update({'creationDate':Date.now()}) else...
Jonathan Doe
1

votes
1

answer
93

Views

How can I send a notification by using the email inserted by another user who requested the notification using Cloud Functions for Firebase?

I'm a beginner on Cloud Functions for Firebase and I'm developing a web app using it to send notifications to specific users. However, the problem is that I want to let the user decid for who he wants to send the message, and the way I've found out to do this was allowing the user to insert through...
Felipe A.
1

votes
1

answer
91

Views

Firebase Dynamic Hosting Rewrite the home page

I am using Firebase dynamic hosting and would like the home page on my website (https://website.com) to redirect to a cloud function while all other urls are directed to a React app. I have tried this in Firebase.json. But it doesn't seem to work. 'rewrites': [ { 'source': '/', 'function': 'app'}, {...
Vincent Cheong
1

votes
1

answer
418

Views

Using Firebase Cloud Functions to Update Hosted File

I am building a site that is using Angular 4, Firebase, and Firebase Cloud Functions. What I am looking to do is when certain data is added to the database I want to add, remove, or update something in an RSS feed, sitemap, and JSON feed which are files hosted with Firebase Hosting. Any suggestions...
Matt Geiser

View additional questions