首页 > 解决方案 > 错误代码 16 和错误代码 14,带有调度云功能

问题描述

我的预定云功能出现这两个错误,这些功能运行良好,但在我的日志中我得到了这些:

Error: 14 UNAVAILABLE: No connection established
at Object.callErrorFromStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client.js:175:52)
at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:341:141)
at Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:304:181)
at Http2CallStream.outputStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:116:74)
at Http2CallStream.maybeOutputStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:155:22)
at Http2CallStream.endCall (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:141:18)
at Http2CallStream.cancelWithStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:457:14)
at ChannelImplementation.tryPick (/workspace/node_modules/@grpc/grpc-js/build/src/channel.js:237:32)
at Object.updateState (/workspace/node_modules/@grpc/grpc-js/build/src/channel.js:106:26) 

和这个:

Error: Process exited with code 16
at process.on.code (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:396:29)
at process.emit (events.js:198:13)
at process.EventEmitter.emit (domain.js:448:20)
at process.exit (internal/process/per_thread.js:168:15)
at logAndSendError (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:184:9)
at process.on.err (/layers/google.nodejs.functions-framework/functions-framework/node_modules/@google-cloud/functions-framework/build/src/invoker.js:393:13)
at process.emit (events.js:198:13)
at process.EventEmitter.emit (domain.js:448:20)
at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)
at process._tickCallback (internal/process/next_tick.js:69:34) 

这是我的代码:我每 5 分钟运行一次用于测试目的的函数,它将在每个月的每一天运行一次。

import * as functions from "firebase-functions";
import * as admin from "firebase-admin";

/// Checks every day if the debt pay day is equal to the setting and add the corresponding amount to 
/// the debt
export const checkForMonthChange = functions.pubsub
  .schedule("every 5 minutes")
  .onRun(async (context) => {
    const configData = await admin
      .firestore()
      .doc("neighbors/0000_admin")
      .get();
    const dayToPay = configData.data()?.day_of_month_to_pay;
    console.log(`Day to Pay: ${dayToPay}`);
    const dayOfMonth = admin.firestore.Timestamp.now()
      .toDate()
      .toString()
      .substr(8, 2);
    console.log(`Current Day of Month: ${dayOfMonth}`);

    if (dayOfMonth === dayToPay) {
      return admin
        .firestore()
        .collection("neighbors")
        .get()
        .then((snapshot) => {
          snapshot.forEach((doc) => {
            return doc.ref.update({
              debt: doc.data()?.debt + configData?.data()?.monthly_pay,
            });
          });
        });
    } else {
      return null;
    }
  });

标签: typescriptfirebasegoogle-cloud-firestoregoogle-cloud-functions

解决方案


推荐阅读