您好我已尝试为此错误提供的所有解决方案,包括使用.once('value')而不是.on('value')。但是我无法解决它。我的代码[如下所示]运行了大约2-3天的时间,然后崩溃并出现以下错误。
RangeError: Maximum call stack size exceeded
at JSON.stringify (<anonymous>)
at A (/home/qymspace/Code/threeneelchannel/node_modules/firebase-admin/lib/database/database.js:57:351)
at Pf.h.send (/home/qymspace/Code/threeneelchannel/node_modules/firebase-admin/lib/database/database.js:161:146)
at sg (/home/qymspace/Code/threeneelchannel/node_modules/firebase-admin/lib/database/database.js:177:164)
at hg.ua (/home/qymspace/Code/threeneelchannel/node_modules/firebase-admin/lib/database/database.js:174:158)
at Object.ua (/home/qymspace/Code/threeneelchannel/node_modules/firebase-admin/lib/database/database.js:233:302)
at kh.h.ua (/home/qymspace/Code/threeneelchannel/node_modules/firebase-admin/lib/database/database.js:222:143)
at uh (/home/qymspace/Code/threeneelchannel/node_modules/firebase-admin/lib/database/database.js:227:82)
at th (/home/qymspace/Code/threeneelchannel/node_modules/firebase-admin/lib/database/database.js:226:435)
at kh.h.put (/home/qymspace/Code/threeneelchannel/node_modules/firebase-admin/lib/database/database.js:226:258)
我的代码是:
const firebase = require('firebase-admin');
const Queue = require('firebase-queue')
const serviceAccount = require("./threeneel-5ad39-firebase-adminsdk-2wjww-145ef9bc19.json");
const config = {
credential: firebase.credential.cert(serviceAccount),
databaseURL: "https://threeneel-5ad39.firebaseio.com",
};
firebase.initializeApp(config);
const database = firebase.database();
var count =0;
var newPosts = [];
var posts=[]
var key="key"
var number= 0
posts=data.posts;
key=data.key;
number= posts.length;
console.log('database.isNew: key: ',key);
const queueRef = database.ref('channel/queue')
posts.forEach((item)=>{
queueRef.child('tasks').push({item});
})
var queue = new Queue(queueRef,function(data,progress,resolve,reject){
//do processing on queue
database.ref('/channel/posts').child(link2id(data.item.link)).once('value',(snapshot)=>{
if(snapshot.val()===null){
newPosts.push(data.item)
}
count++;
console.log('Number: ',number," Count: ",count,'Link: ',data.item.link);
if(count < number){
resolve()
}
else{
count=0;
resolve();
console.log('database.isNew(2): Key: ',key);
onReceive({key:JSON.parse(JSON.stringify(key)),posts:JSON.parse(JSON.stringify(newPosts))})
newPosts=[];
}
})
});
当我检查firebase数据使用页面时,使用率约为5%,我认为这个数字非常小。 Firebase data usage: Downloads