Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

javascript - Firebase-Functions error after update. What can I do?

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)

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) });

});

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

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...