Firebase-tools: 函数模拟器只维护最后一个实时数据库触发器

创建于 2019-07-18  ·  6评论  ·  资料来源: firebase/firebase-tools

[必需] 环境信息


火力基地工具:
火力基地:7.1.1
节点:v10.16.0
爪哇:11.0.2


平台:
苹果系统

[必需] 测试用例

它出现在这一行, firebase-tools/functionsEmulator.ts at dad143c42445056014f6f48cc9dfa13156e3c186 · firebase/firebase-tools · GitHub
,添加新触发器的请求会覆盖之前添加的触发器而不是添加到列表中

[必需] 重现步骤

curl ' http://localhost :9000/.settings/functionTriggers.json?ns=test-project' -X PUT -H 'authorization: Bearer owner' --data-binary '[{"name":"projects/test -project/locations/_/functions/NewPost","path":"/posts/{ownerId}/{postId}","event":"providers/google.firebase.database/eventTypes/ref.create"," topic":"projects/test-project/topics/NewPost"}]' --compressed
{“状态”:“好的”}

curl ' http://localhost :9000/.settings/functionTriggers.json?ns=test-project' -H 'authorization: Bearer owner' --compressed
[{"name":"projects/test-project/locations/_/functions/NewPost","path":"/posts/{ownerId}/{postId}","event":"providers/google.firebase. database/eventTypes/ref.create","topic":"projects/test-project/topics/NewPost"}]

curl ' http://localhost :9000/.settings/functionTriggers.json?ns=test-project' -X PUT -H 'authorization: Bearer owner' --data-binary '[{"name":"projects/test -project/locations/_/functions/UpdatePost","path":"/posts/{ownerId}/{postId}","event":"providers/google.firebase.database/eventTypes/ref.update"," topic":"projects/test-project/topics/UpdatePost"}]' --compressed
{“状态”:“好的”}

curl ' http://localhost :9000/.settings/functionTriggers.json?ns=test-project' -H 'authorization: Bearer owner' --compressed
[{"name":"projects/test-project/locations/_/functions/UpdatePost","path":"/posts/{ownerId}/{postId}","event":"providers/google.firebase. database/eventTypes/ref.update","topic":"projects/test-project/topics/UpdatePost"}]

[必需] 预期行为

这两个数据库触发器都将添加并列在数据库模拟器中

[必需] 实际行为

每个调用都覆盖上一个调用

emulator-suite database functions bug

所有6条评论

@gpfunk感谢您报告此事! 我现在将对此进行调查,看看是否可以重现。

确认这是一个错误,现在找到它所在的位置。

神速:)

好的,这是“按预期工作但仍然是错误”的事情之一。 基本上, firebase-tools代码(如您所见)将PUT发送到每个函数的整个functionTriggers资源,并替换它。

我们真正需要的是在 RTDB 模拟器中实现的“upsert”操作,我们可以使用触发器名称作为唯一 ID 调用该操作。 这就是 Firestore 所拥有的。 我们今天将讨论它,并希望得到一个解决方案。

认为可能是这种情况,感谢您的快速反馈!

@IanWyszynski将尝试添加一个“upsert”操作。

此页面是否有帮助?
0 / 5 - 0 等级