Firebase:Cloud函数触发器:六个隐藏“_xxxxx";触发云功能的新集合中的文档

Firebase:Cloud函数触发器:六个隐藏“_xxxxx";触发云功能的新集合中的文档,firebase,flutter,dart,google-cloud-firestore,google-cloud-functions,Firebase,Flutter,Dart,Google Cloud Firestore,Google Cloud Functions,我最近将我的谷歌云功能升级到Node.js 10。我在触发云函数的新集合中遇到了奇怪的隐藏文档。以下是文档: _createTime _fieldsProto _读取时间 _ref _序列化程序 _更新时间 我的代码中不存在这些文档字符串名称。 但它们确实存在于DocumentSnapshot的构造函数中: 我有一个云函数,它在创建带有示例路径的文档时触发('followers/{userId}/userFollowers/{followerId}')。现在有三次新用户,并且首次创建此子集合 作

我最近将我的谷歌云功能升级到Node.js 10。我在触发云函数的新集合中遇到了奇怪的隐藏文档。以下是文档:

_createTime
_fieldsProto
_读取时间
_ref
_序列化程序
_更新时间

我的代码中不存在这些文档字符串名称。
但它们确实存在于DocumentSnapshot的构造函数中:

我有一个云函数,它在创建带有示例路径的文档时触发('followers/{userId}/userFollowers/{followerId}')。现在有三次新用户,并且首次创建此子集合

作为临时解决办法,我告诉函数忽略与这些隐藏文档名匹配的[followerId]。然而,我有30多个函数在文档创建时触发,我不想在每个函数的顶部永久地使用这种破解方法

还有其他人经历过吗?知道发生了什么吗

以下是我的颤振/飞镖代码,可供用户使用:

followUser(String followerId) async {
    await getUserRef(uid: followerId).get().then((doc) {
      if (!doc.exists) return;
      documentUpdate(
          docRef: getFollowersRef(fid: followerId, uid: currentUser.id),
          payload: {
             //PAYLOAD EXAMPLE:
            'notificationToken': currentUser.notificationToken, //String
            'username': currentUser.username, //String
            'ofUsername': doc.data['username'], //String
            'profileImgURL': currentUser.photoUrl, //String
            'timestamp': DateTime.now(),  //Timestamp
            'displayName': currentUser.displayName, //String
          });
      documentUpdate(
          docRef: getFollowingRef(uid: currentUser.id, fid: followerId),
          payload: {
            // follower data. Same as above but inverted for follower.
          });
    });
  }

documentUpdate({DocumentReference docRef, Map<String, dynamic> payload}) {
   return docRef.setData(payload, merge: true);
}
这里是一个云函数控制台输出的示例,当尝试这些奇数文档时。理解起来很混乱,但很明显,这些奇怪的文档是在预期的文档之后触发的。云函数抛出错误,因为这些奇怪的文档不包含函数完成所需的数据

7:16:25.473 PM
onNewFollower
Function execution started
7:16:26.535 PM
onNewFollower
uid: [Du1orkZrykWJ1BL0kKOuj4HO0ji2], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:16:27.442 PM
onNewFollower
Function execution took 1971 ms, finished with status: 'ok'
7:17:14.663 PM
onNewFollower
Function execution started 
7:17:14.677 PM
onNewFollower
uid: [_ref], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:14.684 PM
onNewFollower
Function execution took 21 ms, finished with status: 'error'
7:17:15.342 PM
onNewFollower
Function execution started
7:17:15.352 PM
onNewFollower
Function execution took 11 ms, finished with status: 'ok'
7:17:15.659 PM
onNewFollower
Function execution started
7:17:15.664 PM
onNewFollower
uid: [_createTime], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:15.666 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:15.667 PM
onNewFollower
Function execution took 31 ms, finished with status: 'error'
7:17:15.790 PM
onNewFollower
Function execution started
7:17:15.797 PM
onNewFollower
Function execution took 7 ms, finished with status: 'ok'
7:17:16.682 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:17.467 PM
onNewFollower
Function execution started
7:17:17.616 PM
onNewFollower
Function execution started
7:17:17.948 PM
onNewFollower
Function execution started
7:17:18.288 PM
onNewFollower
Function execution started
7:17:18.664 PM
onNewFollower
uid: [_readTime], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:19.069 PM
onNewFollower
Function execution took 1603 ms, finished with status: 'error'
7:17:19.363 PM
onNewFollower
uid: [_updateTime], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:19.430 PM
onNewFollower
uid: [_serializer], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:19.863 PM
onNewFollower
Function execution took 2247 ms, finished with status: 'error' 
7:17:19.878 PM
onNewFollower
Function execution took 1931 ms, finished with status: 'error'
7:17:19.960 PM
onNewFollower
uid: [_fieldsProto], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:20.089 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:20.417 PM
onNewFollower
Function execution took 2129 ms, finished with status: 'error'
7:17:20.923 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:20.928 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:21.428 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:36.561 PM
onNewFollower
Function execution started
7:17:36.572 PM
onNewFollower
Function execution took 11 ms, finished with status: 'ok'
7:17:37.567 PM
onNewFollower
Function execution started
7:17:37.581 PM
onNewFollower
Function execution took 15 ms, finished with status: 'ok'
7:17:41.263 PM
onNewFollower
Function execution started
7:17:41.370 PM
onNewFollower
Function execution took 108 ms, finished with status: 'ok'
7:17:42.070 PM
onNewFollower
Function execution started
7:17:42.853 PM
onNewFollower
Function execution took 785 ms, finished with status: 'ok'
7:24:25.667 PM
onNewFollower
Function execution started
7:24:26.775 PM
onNewFollower
uid: [ilxBwWHVDiVJ2iR4AsfIxrpIUgb2], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:24:27.567 PM
onNewFollower
Function execution took 1901 ms, finished with status: 'ok'
文档编写成功,集合中没有显示任何零星文档

我将此问题发布给了FlightFire团队。他们告诉我这实际上是插件的一个问题,修复程序将在即将到来的软件包更新中推出…

我将此问题发布给了FlatterFire团队。他们告诉我,这实际上是插件的问题,修复程序将在即将到来的软件包更新中推出…

1)节点10的工作原理与节点8没有任何不同。2) Firestore中没有“隐藏文档”之类的东西。所有文档都是同等可见的,无论它们的ID是什么。如果看不到您的代码和源数据,我们就无法诊断这里发生的任何事情。请编辑该问题,以便更清楚地了解如何重现该行为,以及您期望的结果。在Dart和cloud函数片段中添加了follow函数的代码。我无法在follow函数上方看到问题,因为“getUserRef(fid:“\u serializer”,uid:currentUser.id)”文档不存在,将退出该函数。此问题仅在首次创建此子集合时出现。需要显示“Do stuff”。请提供足够的信息,任何人都可以重现问题,并观察您也观察到了什么。我建议尝试使用记录文档ID的最小云函数重现问题。如果您不能像那样复制它,请添加可能导致问题的最小代码位。继续执行此操作,直到重现问题,并仅使用该代码更新查询。另见。在这里,您可以看到firestore1)节点10上的文档构造函数中存在的每个字段的工作原理与节点8没有任何不同。2) Firestore中没有“隐藏文档”之类的东西。所有文档都是同等可见的,无论它们的ID是什么。如果看不到您的代码和源数据,我们就无法诊断这里发生的任何事情。请编辑该问题,以便更清楚地了解如何重现该行为,以及您期望的结果。在Dart和cloud函数片段中添加了follow函数的代码。我无法在follow函数上方看到问题,因为“getUserRef(fid:“\u serializer”,uid:currentUser.id)”文档不存在,将退出该函数。此问题仅在首次创建此子集合时出现。需要显示“Do stuff”。请提供足够的信息,任何人都可以重现问题,并观察您也观察到了什么。我建议尝试使用记录文档ID的最小云函数重现问题。如果您不能像那样复制它,请添加可能导致问题的最小代码位。继续执行此操作,直到重现问题,并仅使用该代码更新查询。另见。在这里,您可以看到firestore上文档的构造函数中存在的每个字段
7:16:25.473 PM
onNewFollower
Function execution started
7:16:26.535 PM
onNewFollower
uid: [Du1orkZrykWJ1BL0kKOuj4HO0ji2], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:16:27.442 PM
onNewFollower
Function execution took 1971 ms, finished with status: 'ok'
7:17:14.663 PM
onNewFollower
Function execution started 
7:17:14.677 PM
onNewFollower
uid: [_ref], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:14.684 PM
onNewFollower
Function execution took 21 ms, finished with status: 'error'
7:17:15.342 PM
onNewFollower
Function execution started
7:17:15.352 PM
onNewFollower
Function execution took 11 ms, finished with status: 'ok'
7:17:15.659 PM
onNewFollower
Function execution started
7:17:15.664 PM
onNewFollower
uid: [_createTime], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:15.666 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:15.667 PM
onNewFollower
Function execution took 31 ms, finished with status: 'error'
7:17:15.790 PM
onNewFollower
Function execution started
7:17:15.797 PM
onNewFollower
Function execution took 7 ms, finished with status: 'ok'
7:17:16.682 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:17.467 PM
onNewFollower
Function execution started
7:17:17.616 PM
onNewFollower
Function execution started
7:17:17.948 PM
onNewFollower
Function execution started
7:17:18.288 PM
onNewFollower
Function execution started
7:17:18.664 PM
onNewFollower
uid: [_readTime], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:19.069 PM
onNewFollower
Function execution took 1603 ms, finished with status: 'error'
7:17:19.363 PM
onNewFollower
uid: [_updateTime], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:19.430 PM
onNewFollower
uid: [_serializer], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:19.863 PM
onNewFollower
Function execution took 2247 ms, finished with status: 'error' 
7:17:19.878 PM
onNewFollower
Function execution took 1931 ms, finished with status: 'error'
7:17:19.960 PM
onNewFollower
uid: [_fieldsProto], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:17:20.089 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:20.417 PM
onNewFollower
Function execution took 2129 ms, finished with status: 'error'
7:17:20.923 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:20.928 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:21.428 PM
onNewFollower
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field "username"). at Object.validateUserInput (/workspace/node_modules/@google-cloud/firestore/build/src/serializer.js:251:15) at validateDocumentData (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:610:22) at WriteBatch.set (/workspace/node_modules/@google-cloud/firestore/build/src/write-batch.js:232:9) at DocumentReference.set (/workspace/node_modules/@google-cloud/firestore/build/src/reference.js:338:14) at exports.onNewFollower.functions.firestore.document.onCreate (/workspace/index.js:842:99) at cloudFunction (/workspace/node_modules/firebase-functions/lib/cloud-functions.js:131:23) at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:330:28) at process._tickCallback (internal/process/next_tick.js:68:7)
7:17:36.561 PM
onNewFollower
Function execution started
7:17:36.572 PM
onNewFollower
Function execution took 11 ms, finished with status: 'ok'
7:17:37.567 PM
onNewFollower
Function execution started
7:17:37.581 PM
onNewFollower
Function execution took 15 ms, finished with status: 'ok'
7:17:41.263 PM
onNewFollower
Function execution started
7:17:41.370 PM
onNewFollower
Function execution took 108 ms, finished with status: 'ok'
7:17:42.070 PM
onNewFollower
Function execution started
7:17:42.853 PM
onNewFollower
Function execution took 785 ms, finished with status: 'ok'
7:24:25.667 PM
onNewFollower
Function execution started
7:24:26.775 PM
onNewFollower
uid: [ilxBwWHVDiVJ2iR4AsfIxrpIUgb2], fid: [LtiIcZ8rrphcEnyCWnieKvte6ln2]
7:24:27.567 PM
onNewFollower
Function execution took 1901 ms, finished with status: 'ok'