由于未知错误,触发firebase消息传递的firebase函数失败
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
const messaging = admin.messaging();
export const sendChatNotification = functions.firestore.document('chats/{chatId}/messages/{messageId}').onCreate(async (snapshot) => {
const message = {
notification: {
title: `Message from test`,
body: `You have a new message from test`
},
topic: 'ueyANM8p3kSGaeVpVBcVw6cCzYK2',
data: {
chatId: snapshot.id,
},
};
return messaging.send(message)
}
我得到的错误-
[debug] [2023-01-15T21:09:02.049Z] Error: Failed to update function sendChatNotification in region us-central1
at /opt/homebrew/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:41:11
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Fabricator.updateV1Function (/opt/homebrew/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:305:32)
at async Fabricator.updateEndpoint (/opt/homebrew/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:140:13)
at async handle (/opt/homebrew/lib/node_modules/firebase-tools/lib/deploy/functions/release/fabricator.js:78:17)
[error]
[error] Error: There was an error deploying functions
Firebase工具版本-11.13.0,更新至11.14.0,但仍出现相同错误
1条答案
按热度按时间zbdgwd5y1#
您有时发布的错误可能无法直接给予云功能部署的问题。因此,如果您遇到错误,请尝试在初始阶段使用以下步骤进行调试,以更好地了解原因:
1.添加命令行选项--debug”
firebase deploy --debug --only functions
2.检查日志中的消息:
firebase functions:log
乍一看,这似乎是一个初始化firebase管理的问题,因此更新函数时出现错误,因此尝试在导入代码后添加以下内容,并检查是否仍然出现该问题:
还可以查看以下具有类似实现的示例: