云函数响应为500,但firebase日志为空

云函数响应为500,但firebase日志为空,firebase,rest,google-cloud-functions,internal-server-error,Firebase,Rest,Google Cloud Functions,Internal Server Error,因此,我的一个云函数在(据我目前的理解)random场合突然崩溃 该函数用作我们从中接收数据的API的回发URL(POST!)。 提供API的服务会记录错误,这些错误显示云函数的响应为: 500 Server Error Error: Server Error The server encountered an error and could not complete your request. Please try again in 30 seconds. 我附加了一个屏幕截图([1])和一

因此,我的一个云函数在(据我目前的理解)random场合突然崩溃

该函数用作我们从中接收数据的API的回发URL(POST!)。 提供API的服务会记录错误,这些错误显示云函数的响应为:

500 Server Error
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
我附加了一个屏幕截图([1])和一个美化版的html([2]),这是对这个问题的全部回答

当这种行为发生时,我一次最多向API提交350个请求。回发调用会在几分钟内进行(因为API对某些输入的占用时间比对其他输入的占用时间长),所以这不应该是速率/配额/限制的问题

关于这种行为,Firebase云函数日志完全是空的(这是最让我困惑的)。它们只显示成功的回调(相同的函数,相同的数据!)。SO和其他论坛上的一些人指向Google云日志,但我在那里找不到比Firebase云功能日志更多的信息

感谢您的时间和您能提供的任何帮助

My package.json:

{
  "name": "functions",
  "version": "1.0.0",
  "scripts": {
    "lint": "tslint --project tsconfig.json",
    "build": "tsc",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "8"
  },
  "main": "lib/index.js",
  "dependencies": {
    "esm": "^3.2.25",
    "firebase-admin": "^8.6.0",
    "firebase-functions": "^3.6.2",
    "fs": "0.0.1-security",
    "handlebars": "^4.7.6",
    "nodemailer": "^6.4.8",
    "request": "^2.88.2",
    "request-promise": "^4.2.4",
    "request-promise-native": "^1.0.7"
  },
  "devDependencies": {
    "@firebase/app-types": "^0.6.0",
    "@types/node": "^13.13.10",
    "firebase-functions-test": "^0.1.6",
    "prettier": "^1.19.1",
    "tslint": "^5.12.0",
    "typescript": "^3.9.5"
  },
  "private": true
}
简化版本中的云功能:

const scrapeCallbackDFS_v2 = async (request, response) => {
  console.log('resultsCallbackDFS() called ...')

  if (
    request.method === 'POST' &&
    request.body &&
    request.body.status_code === 20000
  ) {

    // extract data from request.url (queryparams)
    // ...

    // extract data from request.body
    // ...

    try {
      const analysedResults = analyseResults(/* extracted data ... */)

      await uploadResult( /* upload to firestore ... */ )

      response
        .set('Access-Control-Allow-Methods', 'POST, OPTIONS, GET')
        .set('Access-Control-Allow-Origin', corsAllowOrigin(request))
        .status(200)
        .end()
      return
    } catch (error) {
      console.log(userId + ' ' + error)
      response
        .status(433)
        .set('Access-Control-Allow-Methods', 'POST, OPTIONS, GET')
        .set('Access-Control-Allow-Origin', corsAllowOrigin(request))
        .send(error)
      return
    }
  } else {
    response
      .status(434)
      .set('Access-Control-Allow-Methods', 'POST, OPTIONS, GET')
      .set('Access-Control-Allow-Origin', corsAllowOrigin(request))
      .send('method:' + request.method)
    return
  }
}

[1] API中有关回调请求的日志:

[2] 对回发请求的美化云函数响应体:

"server response":"HTTP\/1.1 100 Continue
<br \/>
<br \/>HTTP\/1.1 500 Internal Server Error
<br \/>X-Cloud-Trace-Context: 95a8809b1fc9d9313ccc534fb0c61636
<br \/>Date: Mon, 08 Jun 2020 17:35:17 GMT
<br \/>Content-Type: text\/html; charset=UTF-8
<br \/>Server: Google Frontend
<br \/>Content-Length: 323
<br \/>Alt-Svc: h3-27=\":443\"; ma=2592000,h3-25=\":443\";
        ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q050=\":443\"; 
            ma=2592000,h3-Q049=\":443\"; ma=2592000,h3-Q048=\":443\"; 
                ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; 
                    ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"
<br \/>
<br \/>
<br \/>\n
<html>

    <head>
        <br \/>\n
        <meta http-equiv=\ "content-type\" content=\ "text\/html;charset=utf-8\">
        <br \/>\n
        <title>500 Server Error<\/title>
        <br \/>\n
    <\/head>
    <br \/>\n

    <body text=#000000 bgcolor=#ffffff>
        <br \/>\n
        <h1>Error: Server Error<\/h1>
        <br \/>\n
        <h2>The server encountered an error and could not complete your request.
        <p>Please try again in 30 seconds.<\/h2>
        <br \/>\n
        <h2><\/h2>
        <br \/>\n
    <\/body>
<\/html>"
“服务器响应”:“HTTP\/1.1 100继续”

HTTP\/1.1500内部服务器错误
X-Cloud-Trace-Context:95a8809b1fc9d9313ccc534fb0c61636
日期:2020年6月8日星期一17:35:17 GMT
内容类型:text\/html;charset=UTF-8
服务器:谷歌前端
内容长度:323
Alt Svc:h3-27=\“:443\”ma=2592000,h3-25=\“:443\”;
ma=2592000,h3-T050=\”:443\“ma=2592000,h3-Q050=\”:443\”;
ma=2592000,h3-Q049=\”:443\“ma=2592000,h3-Q048=\”:443\”;
ma=2592000,h3-Q046=\“:443\”;ma=2592000,h3-Q043=\“:443\”;
ma=2592000,quic=443;ma=2592000;v=46,43


\n
\n
\n
500服务器错误
\n
\n
\n
错误:服务器错误
\n
服务器遇到错误,无法完成您的请求。
请在30秒后重试。
\n
\n
"

看起来云功能只是告诉您,它还没有扩展到满足对功能的需求。它不会立即扩大。我有没有办法确定这是原因?因为我已经使用这个API半年了,从来没有遇到过这个问题。有时提出(或得到)的请求比这个特殊问题多得多……我不知道,我建议你只是慢慢增加你的负载,看看这是否有帮助。