【发布时间】:2018-12-17 13:35:37
【问题描述】:
调用 GCF 时出现以下错误:
错误:Reference.update 失败:指定的第一个参数路径超过了可写入的最大深度 (32) 或对象在属性中包含循环
在网上做了一些挖掘,但找不到相同的问题。在不添加太多信息的情况下,我正在尝试将菜对象添加到实时数据库中的类别对象中。奇怪的是,该功能在前 6 道菜中运行良好,当我尝试添加第 7 道菜时,弹出此错误并且更新方法失败。
完整的错误日志,带有我唯一的属性数据是:
Error: Reference.update failed: First argument path specified exceeds the maximum depth that can be written (32) or object contains a cycle in property
'users.sIRf7m1uWfa9j0iF6UuuzvdD5TG2.dishcategories.default01.dishes.u3o1p278vriqo3odeslle.categories.0.dishes.irdrl2q7blsi1y7ih3jhh.categories.0.dishes.v8pl7r9llhfp7sqmz7uikk.categories.0.dishes.2ee3ajy6d5vymneewgflze.categories.0.dishes.btdib119nz5cnm6zk5uu4t.categories.0.dishes.4wyu5yqyn2z0bgvcejix9.categories.0.dishes.w1cfcpktym7nkp76p521n.categories.0.createdDate'
at ValidationPath.checkValid_ (/srv/node_modules/@firebase/database/dist/index.node.cjs.js:1035:19)
at ValidationPath.push (/srv/node_modules/@firebase/database/dist/index.node.cjs.js:1015:14)
at /srv/node_modules/@firebase/database/dist/index.node.cjs.js:1478:18
at Object.forEach (/srv/node_modules/@firebase/util/dist/index.node.cjs.js:837:13)
at validateFirebaseData (/srv/node_modules/@firebase/database/dist/index.node.cjs.js:1462:14)
at /srv/node_modules/@firebase/database/dist/index.node.cjs.js:1479:13
at Object.forEach (/srv/node_modules/@firebase/util/dist/index.node.cjs.js:837:13)
at validateFirebaseData (/srv/node_modules/@firebase/database/dist/index.node.cjs.js:1462:14)
at /srv/node_modules/@firebase/database/dist/index.node.cjs.js:1479:13
at Object.forEach (/srv/node_modules/@firebase/util/dist/index.node.cjs.js:837:13)
这里是 index.ts 中的云函数代码:
// Now we need to check if this dish's categories already exist as user categories.
// If they do, we can add this newly created dish into them.
// If they don't, we can create them with this newly added dish in them.
dish.categories.forEach( async (dishCategory) => {
const index = objectInArrayByID(dishCategory, userCategories)
if ( index !== -1 ) {
return userCategoriesRef.child(`${dishCategory.id}/dishes/${id}`).update(dish) // *** This is the update method producing the error in this case ***
}
else {
await userCategoriesRef.child(`${dishCategory.id}`).update(dishCategory)
return userCategoriesRef.child(`${dishCategory.id}/dishes/${id}`).update(dish)
}
})
任何人都知道这个错误是什么意思,也许我在这里做错了什么?谢谢!
【问题讨论】:
标签: node.js firebase firebase-realtime-database google-cloud-functions