1
내 애플 리케이션을위한 데이터 관리를 위해 파이어베이스 용 클라우드 기능을 파이어베이스 리얼 타임 데이터베이스와 함께 사용하고 있습니다.ESOCKETTIMEDOUT Firebase 용 클라우드 기능
내 기능 중 하나는 완료하는 데 약 100-150 초가 걸리기 때문에 종료되는 것처럼 보입니다. 이 오류는 ESOCKETTIMEDOUT
과 함께 발생합니다.
이 문제를 방지 할 방법이 있습니까? 사용자가 환경 설정을 추가 할 때
function getTopCarsForUserWithPreferences(userId, genres) {
const pathToCars = admin.database().ref('cars');
pathTocars.orderByChild("IsTop").equalTo(true).once("value").then(function(snapshot) {
return writeSuggestedCars(userId, genres, snapshot);
}).catch(reason => {
console.log(reason)
})
}
function writeSuggestedCars(userId, genres, snapshot) {
const carsToWrite = {};
var snapCount = 0
snapshot.forEach(function(carSnapshot) {
snapCount += 1
const carDict = carSnapshot.val();
const carGenres = carDict.taCarGenre;
const genre_one = genres[0];
const genre_two = genres[1];
if (carGenres[genre_one] === true ||carGenres[genre_two] == true) {
carsToWrite[carSnapshot.key] = carDict
}
if (snapshot.numChildren() - 1 == snapCount) {
const pathToSuggest = admin.database().ref('carsSuggested').child(userId);
pathToSuggest.set(carsToWrite).then(snap => {
}).catch(reason => {
console.log(reason)
});
}
});
}
getTopCarsForUserWithPreferences
가 호출됩니다 :
여기 내 기능입니다. 또한 cars
테이블에는 약 50,000 개의 항목이 있습니다.