Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

node.js - Problem deploying function to Cloud Firestore

I'm trying to deploy a simple function do Cloud Firestore. This function will patch the data. But whenever I attempt to deploy I get an error:

Functions deploy had errors with the following functions:
    webApi

This is the code:

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
import * as firebaseHelper from 'firebase-functions-helper/dist';
import * as express from 'express';
import * as bodyParser from 'body-parser';

admin.initializeApp(functions.config().firebase);
const db = admin.firestore();

const app = express();
const main = express();

main.use(bodyParser.json());
main.use(bodyParser.urlencoded({extended: false}));
main.use('/api/v1', app);

const sensorsCollection = 'dadosusuarios';
export const webApi = functions.https.onRequest(main);

app.patch('/Name/:sensorId', async(req, res) => {
    try{
        await firebaseHelper.firestoreHelper.updateDocument(db, sensorsCollection, req.params.sensorId, req.body);
        res.status(200).send('Update Success');
    }catch(error){
        res.status(204).send('Patch Error');
    }
})

Database image: enter image description here

This is the error log I got from debbuging the code:

{
textPayload: "ERROR"
insertId: "da-das-47d7-925a-da-29"
resource: {2}
timestamp: "2021-01-27T01:39:05.703003866Z"
severity: "INFO"
labels: {1}
logName: "projects/automacao-com-aplicativo/logs/cloudbuild"
receiveTimestamp: "2021-01-27T01:39:05.952913755Z"
}

textPayload: "ERROR: error fetching storage source: generic::unknown: retry budget exhausted (3 attempts): fetching gcs source: unpacking source from gcs: source fetch container exited with non-zero status: 1"
insertId: "a528e7ab-dsa-47d7-dsa-9bcc6b5624bb-30"
resource: {2}
timestamp: "2021-01-27T01:39:05.703023756Z"
severity: "INFO"
labels: {1}
logName: "projects/automacao-com-aplicativo/logs/cloudbuild"
receiveTimestamp: "2021-01-27T01:39:05.952913755Z"
}
question from:https://stackoverflow.com/questions/65911661/problem-deploying-function-to-cloud-firestore

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I ran into a similar issue with the same error message.

Are you deploying from your computer? If so, make sure you are using Node 12 when you deploy.

To check your current Node version, you can use node --version. If you need multiple Node versions (for different projects), I would suggest using nvm. Otherwise, you can follow this answer to a similar question to downgrade.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...