Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6290

Why isn't this simple Firebase function able to deploy?

$
0
0

I'd like to create a simple cloud function to add een newly created user to Firestore:

./firebaseConfig.ts :

const app = initializeApp({  ...});export const fireStoreDB = getFirestore(app);

./functions/index.ts :

import * as functions from 'firebase-functions';import {DocumentData, DocumentReference, doc, setDoc} from 'firebase/firestore';import {fireStoreDB} from '../../firebaseConfig';const createDocumentReferenceHelper = <T = DocumentData>(    collectionStartingPath: string,    collectionPath: string[],) => {    return doc(        fireStoreDB,        collectionStartingPath,        ...collectionPath,    ) as DocumentReference<T>;};export const newUser = functions.auth.user().onCreate(async (user) => {    const docRef = createDocumentReferenceHelper('users', [user.uid]);    await setDoc(docRef, {email: user.email});});

Upon deploying I get the following error:

✔  functions: Finished running predeploy script.i  functions: ensuring required API cloudfunctions.googleapis.com is enabled...i  functions: ensuring required API cloudbuild.googleapis.com is enabled...i  artifactregistry: ensuring required API artifactregistry.googleapis.com is enabled...✔  artifactregistry: required API artifactregistry.googleapis.com is enabled✔  functions: required API cloudfunctions.googleapis.com is enabled✔  functions: required API cloudbuild.googleapis.com is enabledi  functions: preparing codebase default for deploymenti  functions: preparing functions directory for uploading...i  functions: packaged /Users/<user>/<project>/functions (105.98 KB) for uploading✔  functions: functions folder uploaded successfullyi  functions: updating Node.js 16 function newUser(us-central1)...Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.Functions deploy had errors with the following functions:    newUser(us-central1)i  functions: cleaning up build files...Error: There was an error deploying functions

I've tried:

  • Using the same 'newUser functionality' outside of the Cloud function, which works just fine.

  • Replaced newUser function with a http hello world function, which deployed & works without problems.

  • Looked into the error logs, but they just repeat the message that the code is wrong.

I expected:

This to be way less of a hassle ;). I believe I'm overthinking it and am missing something very simple.

Any help / push in the right direction will be appreciated!


Viewing all articles
Browse latest Browse all 6290

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>