0
当你删除一个文件(特别是在这种情况下,照片)通过云火力地堡火力地堡的功能存储和云功能,一些文件被删除很好,有的留在火力地堡存储。当文件未被删除时,我在日志中收到错误,错误文本。的火力地堡错误
Error: read ECONNRESET at exports._errnoException (util.js:1026:11) at TCP.onread (net.js:569:26)
Error: read ECONNRESET
at exports._errnoException (util.js:1026:11)
at TCP.onread (net.js:569:26)
我的代码
var functions = require('firebase-functions');
const admin = require('firebase-admin');
const gcs = require('@google-cloud/storage')();
admin.initializeApp(functions.config().firebase);
// deleting functions
exports.userDidDeleted = functions.auth.user().onDelete(event => {
const user = event.data; // The Firebase user.
const email = user.email; // The email of the user.
const displayName = user.displayName; // The display name of the user.
const userSearchLocationModelPath = '/userSearchLocationModel/' + user.uid;
console.log('userDidDeleted', userSearchLocationModelPath);
admin.database().ref(userSearchLocationModelPath).remove();
// cards
var cardsRef = admin.database().ref('cards')
cardsRef.orderByChild('ownerID').equalTo(user.uid).on("child_added", function(snapshot) {
console.log('cardsRef', snapshot.key, snapshot.val);
const cardRef = '/cards/' + snapshot.key;
admin.database().ref(cardRef).remove();
// location
admin.database().ref('cardLocation').child(snapshot.key).remove();
// photo
const filePath = 'cardImages/' + snapshot.key + '/mainCardPhoto/' + 'main.jpg';
const bucket = gcs.bucket('example-example7.appspot.com');
const file = bucket.file(filePath);
const pr = file.delete();
});
});
ECONNRESET意味着你没有返回的承诺。通过返回你的承诺,函数等待清理,直到所有的工作完成。这里有几件事情要检查,以了解更多:https://firebase.google.com/docs/functions/terminate-functions https://www.youtube.com/watch?v=NgZIb6Uwpjc&spfreload=5 –
@ JenPerson非常感谢你 – Alexander