我在这里扯头发:
我有一个如下所示的云功能:
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
我在这里想念什么?
答案 0 :(得分:3)
好吧,问题最终出在该功能部署不正确。
发生的事情是由于某些打字稿/ firebase配置问题-新代码被编译到了firebase所不希望的位置。
在部署代码后-一些旧的已编译代码仍在那里部署。
这里的故事的寓意是:请确保在部署之前删除dist / build / lib目录-因为如果firebase在错误的位置查看,则将导致错误。
答案 1 :(得分:2)
以防有人浪费我的时间。原来我登录了错误的Firebase项目??♂️。
firebase projects:list
您当前的项目将以蓝色突出显示,旁边带有“(当前)”。
如果您需要更改项目:
firebase use insert-project-id-here