我已经将我的Firebase函数index.ts缩减为以下代码,当创建文档时,我在Google Cloud日志(log)中收到错误.该错误与new CloudTasksClient()
有关.如果我删除它,只记录一个简单的字符串,那么当创建文档时,我看到的是记录和日志(log),没有错误.@google-cloud/任务更新.即使我只是try 在没有实例化的情况下记录logger.log('CloudTasksClient', CloudTasksClient);
,我也会收到这些错误,这似乎指向了一个重要的问题,但我无论如何也找不出它是什么.有什么主意吗?
import { initializeApp } from 'firebase-admin/app';
import * as logger from 'firebase-functions/logger';
import { onDocumentCreated } from 'firebase-functions/v2/firestore';
import { CloudTasksClient } from '@google-cloud/tasks';
initializeApp();
export const onStartSession = onDocumentCreated(
'userSessionInfo/{userId}/history/{sessionId}',
async () => {
const project: string = /* removed */;
const location: string = 'us-central1';
const queue: string = 'delay';
const tasksClient = new CloudTasksClient();
const queuePath = tasksClient.queuePath(project, location, queue);
logger.log('queuePath', queuePath);
},
);
以下是错误所在.这个类似乎是未定义的,它抛出了第二个错误,然后第一个错误来自Firebase,因为这个未定义的错误导致在创建文档时无法创建快照?
Error: Failed to decode protobuf and create a snapshot.
at entryFromArgs (/workspace/node_modules/firebase-functions/lib/logger/index.js:130:19)
at Object.error (/workspace/node_modules/firebase-functions/lib/logger/index.js:116:11)
at createSnapshotFromProtobuf (/workspace/node_modules/firebase-functions/lib/common/providers/firestore.js:61:16)
at createSnapshot (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:119:59)
at makeFirestoreEvent (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:156:15)
at func (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:222:32)
at /layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/function_wrappers.js:113:25
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
TypeError: Cannot read properties of undefined (reading 'cloud')
at Function.decode (/workspace/node_modules/firebase-functions/protos/compiledFirestore.js:1529:130)
at createSnapshotFromProtobuf (/workspace/node_modules/firebase-functions/lib/common/providers/firestore.js:57:52)
at createSnapshot (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:119:59)
at makeFirestoreEvent (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:156:15)
at func (/workspace/node_modules/firebase-functions/lib/v2/providers/firestore.js:222:32)