更新后的 Firebase-Functions 错误.我能做什么? [英] Firebase-Functions error after update. What can I do?

查看:22
本文介绍了更新后的 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 错误.我能做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆