Javascript 云功能部署失败
我正在尝试使用CloudFireStore作为触发器来部署我的云功能。云函数只监听firestore路径上的任何新文档创建,并将新数据记录到控制台。但是,功能部署失败,并且没有明确的错误消息。你能帮我找出问题所在吗 云功能代码:Javascript 云功能部署失败,javascript,google-cloud-firestore,google-cloud-functions,Javascript,Google Cloud Firestore,Google Cloud Functions,我正在尝试使用CloudFireStore作为触发器来部署我的云功能。云函数只监听firestore路径上的任何新文档创建,并将新数据记录到控制台。但是,功能部署失败,并且没有明确的错误消息。你能帮我找出问题所在吗 云功能代码: const functions = require('firebase-functions'); exports.createUser = functions.firestore .document('test_restaurant/{id}/reviews/
const functions = require('firebase-functions');
exports.createUser = functions.firestore
.document('test_restaurant/{id}/reviews/{id}')
.onCreate((snap, context) => {
console.log(snap.data());
});
2020-06-28 18:51:03.110 IST
Cloud Functions
UpdateFunction
asia-east2:function-test-2
abc@gmail.com
Function failed on loading user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs
Expand all | Collapse all
{
insertId: "5u231ccch0"
logName: "projects/fs-22/logs/cloudaudit.googleapis.com%2Factivity"
operation: {
id: "operations/ZmlyZXN0b3JlLTI0OTcwNS9hc2lhLWVhc3QyL2Z1bmN0aW9uLXRlc3QtMi9xOVJCbHpESzdjSQ"
last: true
producer: "cloudfunctions.googleapis.com"
}
protoPayload: {
@type: "type.googleapis.com/google.cloud.audit.AuditLog"
authenticationInfo: {
principalEmail: "abc@gmail.com"
}
methodName: "google.cloud.functions.v1.CloudFunctionsService.UpdateFunction"
resourceName: "projects/fs-22/locations/asia-east2/functions/function-test-2"
serviceName: "cloudfunctions.googleapis.com"
status: {
code: 3
message: "Function failed on loading user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs"
}
}
receiveTimestamp: "2020-06-28T13:21:03.364975479Z"
resource: {
labels: {
function_name: "function-test-2"
project_id: "fs-22"
region: "asia-east2"
}
type: "cloud_function"
}
severity: "ERROR"
timestamp: "2020-06-28T13:21:03.110Z"
}
错误日志:
const functions = require('firebase-functions');
exports.createUser = functions.firestore
.document('test_restaurant/{id}/reviews/{id}')
.onCreate((snap, context) => {
console.log(snap.data());
});
2020-06-28 18:51:03.110 IST
Cloud Functions
UpdateFunction
asia-east2:function-test-2
abc@gmail.com
Function failed on loading user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs
Expand all | Collapse all
{
insertId: "5u231ccch0"
logName: "projects/fs-22/logs/cloudaudit.googleapis.com%2Factivity"
operation: {
id: "operations/ZmlyZXN0b3JlLTI0OTcwNS9hc2lhLWVhc3QyL2Z1bmN0aW9uLXRlc3QtMi9xOVJCbHpESzdjSQ"
last: true
producer: "cloudfunctions.googleapis.com"
}
protoPayload: {
@type: "type.googleapis.com/google.cloud.audit.AuditLog"
authenticationInfo: {
principalEmail: "abc@gmail.com"
}
methodName: "google.cloud.functions.v1.CloudFunctionsService.UpdateFunction"
resourceName: "projects/fs-22/locations/asia-east2/functions/function-test-2"
serviceName: "cloudfunctions.googleapis.com"
status: {
code: 3
message: "Function failed on loading user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs"
}
}
receiveTimestamp: "2020-06-28T13:21:03.364975479Z"
resource: {
labels: {
function_name: "function-test-2"
project_id: "fs-22"
region: "asia-east2"
}
type: "cloud_function"
}
severity: "ERROR"
timestamp: "2020-06-28T13:21:03.110Z"
}
问题解决了。基本上,错误是在文档路径中使用相同的通配符两次。导致问题的引用是{id},我只是更改了其中一个引用。新路径为:.document('test_restaurant/{id}/reviews/{reviewsId}'),部署成功。问题已解决。基本上,错误是在文档路径中使用相同的通配符两次。导致问题的引用是{id},我只是更改了其中一个引用。新路径为:.document('test_restaurant/{id}/reviews/{reviewsId}),部署成功。检查根文件夹上是否安装了某些依赖项。您应该将所有模块安装在functions文件夹中。根文件夹中只应包含firebase依赖项。尝试执行npm卸载根文件夹中的yourDependencie,然后npm卸载根/函数文件夹中的yourDependencie。检查根文件夹上是否安装了某些依赖项。您应该将所有模块安装在functions文件夹中。根文件夹中只应包含firebase依赖项。尝试执行npm卸载根文件夹中的yourDependencie,然后在根/函数文件夹中卸载npm i yourDependencie。如果您使用的是lint,则需要确保您的代码正在通过
eslint。
命令,否则部署到firebase时会出现错误
{
"@type":"type.googleapis.com/google.cloud.audit.AuditLog",
"status":{
"code":3,
"message":"Function failed on loading user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging"
},
"authenticationInfo":{
"principalEmail":"your_email"
},
"serviceName":"cloudfunctions.googleapis.com",
"methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction",
"resourceName":"projects/your_project/locations/us-central1/functions/your_func"
}
在我的例子中,我通过在索引上分解prettier来修复它,而且,如果你有更多的文件,你必须为每个文件禁用它
/* eslint-disable prettier/prettier */
如果您正在使用lint,您需要确保您的代码正在通过
eslint.
命令,否则部署到firebase时会出现错误
{
"@type":"type.googleapis.com/google.cloud.audit.AuditLog",
"status":{
"code":3,
"message":"Function failed on loading user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging"
},
"authenticationInfo":{
"principalEmail":"your_email"
},
"serviceName":"cloudfunctions.googleapis.com",
"methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction",
"resourceName":"projects/your_project/locations/us-central1/functions/your_func"
}
在我的例子中,我通过在索引上分解prettier来修复它,而且,如果你有更多的文件,你必须为每个文件禁用它
/* eslint-disable prettier/prettier */
错误输出为您提供了检查日志的链接。你试过了吗?是的,日志没有给出任何具体的错误@Doug Stevenson错误输出为您提供检查日志的链接。你试过了吗?是的,日志没有给出任何具体的错误@道格·史蒂文森