gpt4 book ai didi

google-cloud-firestore - Firebase Cloud Functions 上的 console.log 根本不记录日志。

转载 作者:行者123 更新时间:2023-12-02 14:20:42 26 4
gpt4 key购买 nike

我在这里撕扯我的头发:

我有一个如下所示的云函数:

exports.stripeCharge = functions.firestore.document('/payments/{paymentId}')
.onWrite((doc, context) => {
console.log("hello?");

const payment = doc.after.data();

// Snip - What happens here shouldn't affect whether the log show or not right?
});

但是我的日志语句根本没有显示在我的日志上 - 即使执行确实如此。

即。示例日志:

5:04:40.084 PM
stripeCharge
Function execution took 288 ms, finished with status: 'ok'
5:04:40.077 PM
stripeCharge
Function returned undefined, expected Promise or value
5:04:39.797 PM
stripeCharge
Function execution started
5:04:13.583 PM
stripeCharge
Function execution took 10195 ms, finished with status: 'ok'
5:04:07.696 PM
stripeCharge
The behavior for Date objects stored in Firestore is going to change AND YOUR APP MAY BREAK. To hide this warning and ensure your app does not break, you need to add the following code to your app before calling any other Cloud Firestore methods: const firestore = new Firestore(); const settings = {/* your settings... */ timestampsInSnapshots: true}; firestore.settings(settings); With this change, timestamps stored in Cloud Firestore will be read back as Firebase Timestamp objects instead of as system Date objects. So you will also need to update code expecting a Date to instead expect a Timestamp. For example: // Old: const date = snapshot.get('created_at'); // New: const timestamp = snapshot.get('created_at'); const date = timestamp.toDate(); Please audit all existing usages of Date when you enable the new behavior. In a future release, the behavior will change to the new behavior, so if you do not follow these steps, YOUR APP MAY BREAK.
5:04:03.390 PM
stripeCharge
Function execution started

我在这里缺少什么?

最佳答案

好吧,问题最终是函数没有正确部署。

发生的情况是由于某些 typescript/firebase 配置问题 - 新代码被编译到不是 firebase 正在寻找的位置。

部署代码时 - 一些旧的编译代码仍然需要部署。

这里的故事的寓意是:确保在构建之前删除 dist/build/lib 目录 - 因为如果 firebase 在错误的位置查找,这将导致错误。

关于google-cloud-firestore - Firebase Cloud Functions 上的 console.log 根本不记录日志。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51578056/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com