首页 > 解决方案 > 尝试在 Google Cloud Functions 中删除文档时收到内部错误

问题描述

我有一个 cron 调用,它只是像这样删除一个文档:

// expiringBoardPostCronCall
// This function is called to remove all board posts at the nearest expire time
exports.expiringBoardPostCronCall = functions.https.onRequest((request, response) => {
  // Get the current date rounded to nearest 15 minutes, divide by 1000 to convert from ms to s
  const currentTime = Date.now();
  const coeff = 1000 * 60 * 5;
  const roundedTime = ((Math.round(currentTime / coeff)) * coeff) / 1000;
  // Delete the expiring document
  db.collection('expireTimes').doc(roundedTime.toString()).delete().then(snapshot => {
    // Do nothing, the expiring document was removed successfully
    response.end()
    return
  }).catch(error => {
    console.error("Error removing expireTimes document: ", error);
    response.end()
  });
})

我最近从函数日志中收到以下错误:

错误:13 内部:收到带有代码 2 的 RST_STREAM

在 Object.callErrorFromStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call.js:30:26)

在 Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client.js:175:52)

在 Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:341:141)

在 Object.onReceiveStatus (/workspace/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:304:181)

在 Http2CallStream.outputStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:116:74)

在 Http2CallStream.maybeOutputStatus (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:155:22)

在 Http2CallStream.endCall (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:141:18)

在 ClientHttp2Stream.stream.on (/workspace/node_modules/@grpc/grpc-js/build/src/call-stream.js:403:22)

在 ClientHttp2Stream.emit (events.js:198:13)

在 ClientHttp2Stream.EventEmitter.emit (domain.js:466:23)

代码:13,

详细信息:'收到带有代码 2 的 RST_STREAM',

元数据:元数据 { internalRepr:地图 {},选项:{} } }

函数执行耗时 21 ms,完成状态码:200

我一直在关注此处此处列出的 github 线程,但似乎没有一个好的答案。似乎其他人在几乎相同的错误日志中遇到了同样的问题。我在 Node.js 10 中运行。有没有其他人看到这个或有类似的问题?有什么解决办法吗?

标签: node.jsfirebasegoogle-cloud-firestoregoogle-cloud-functions

解决方案


推荐阅读