更新后出现Firebase

更新后出现Firebase

本文介绍了更新后出现Firebase-Functions错误.我能做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我更新了firebase功能,现在在Firebase控制台中收到此错误.代码仍然相同,但现在出现错误:

I updated my firebase-functions and now I get this error in the Firebase console. The code is still the same, but I get an error now:

/srv/node_modules/@google-cloud/firestore/build/src/collection-group.js:54
    async *getPartitions(desiredPartitionCount) {
          ^

SyntaxError: Unexpected token *
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/srv/node_modules/@google-cloud/firestore/build/src/index.js:39:28)

这是我的云函数TypeScript来源:

This is my cloud function TypeScript source:

import * as functions from 'firebase-functions';
import admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

/********************************************************************/

exports.newChatMessage = functions.firestore
  .document('/games/{gameId}/chat/{chatId}')
  .onCreate((snap, context) => {

    const createData = snap.data();
    if(!createData) {
        return false;
    }

    const chatMessage = createData.message;
    if(!chatMessage) {
        return false;
    }

    console.log('New Chat message in game: ', context.params.gameId);

    const payload = {
        notification: {
            title: 'New chat message',
            body: chatMessage,
            icon: 'ic_notification'
        }
    }

    return admin.firestore().collection(`/games/${context.params.gameId}/members`).where( 'notificationChat', '==', true ).get().then( members => {
        members.forEach( member => {
            if(member.id !== createData.user) {
                return admin.firestore().doc(`/users/${member.id}`).get().then( memberdata => {
                    if( memberdata.get('firebaseToken') === '' ) {
                        return memberdata.data();
                    } else {
                        return admin.messaging().sendToDevice(memberdata.get('firebaseToken'), payload).catch( error => { console.log(error) });
                    }
                }).catch( error => { console.log(error) });
            } else {
                return false;
            }
        })
    }).catch( error => { console.log(error) });

});

这是什么?在我的函数中,没有任何名为 * getPartitions 的方法.

What is this? In my functions there isn't any method named *getPartitions.

推荐答案

将firebase-admin和firebase-functions降级至以下版本:"firebase-admin":"^ 8.10.0","firebase-functions":"^ 3.6.1";它将起作用.

Downgrade firebase-admin and firebase-functions to version: "firebase-admin": "^8.10.0", "firebase-functions": "^3.6.1" and it will work.

感谢 Marcel Hoekstra 在评论中发布.

这篇关于更新后出现Firebase-Functions错误.我能做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 17:09