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