Stream removed error in Firebase Functions

对着背影说爱祢 提交于 2019-12-23 01:54:51

问题


I have a function that runs on the creation of a new user. The function typically fails on the first call after not being called for a while. I'm hoping someone could help me figure out what could be causing this.

export const onUserCreate = functions.auth.user().onCreate(event => {

    const user: User = {
        userId: event.data.uid,
        email: event.data.email
    };

    return db.doc(`users/${user.userId}`).set(data);
});


回答1:


As I use the same like below and it works well:

exports.onUserCreate = functions.auth.user().onCreate(event => {
   const user = event.data
   console.log(user);
})



回答2:


This is hardly a permanent answer as this is something Google seems to be looking into.

In the meantime though I did some research on similar error messages across the Google libraries and it looks like it happens occasionally when you initialise a Google library outside of a function (ie. at the top of your file).

I've added this line within the function being executed instead of within the global scope and it looks to have stopped the error:

const datastore = require('@google-cloud/datastore')({});

For example instead of:

const datastore = require('@google-cloud/datastore')({});

module.exports.myFunction = function() {
   datastore.get(key).then()....
}

you do

module.exports.myFunction = function() {
    const datastore = require('@google-cloud/datastore')({});
   datastore.get(key).then()....
}

That would go for Firebase libraries too – not just datastore. This isn't best-practice and should be changed back when the bug is fixed.




回答3:


This seems to be an error with Firebase Functions right now and is being looked into.

EDIT:

Hello all, Sebastian from the Firestore SDK team here. We believe this issue is related to the recent update of the GRPC Client SDK and have been running tests with GRPC 1.7.1. So far, we have not been able to reproduce this issue with this older GRPC version.

@google-cloud/firestore is now at 0.10.1. If you update your dependencies, you will be able to pull in this release.

Thanks for your patience.

Sebastian




回答4:


I had the same issue. Turns out this is a bug in the Firestore Node module. Update @google-cloud/firestore to version 0.10.1 and it should fix the issue.



来源:https://stackoverflow.com/questions/47870711/stream-removed-error-in-firebase-functions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!