title: cloud functions responds with 500, but firebase logs empty
body: <p>so one of my cloud functions suddenly crashes on (to my current understanding) <strong>random</strong> occasions.</p>
  
  <p>The function is used as a postback-URL (<strong>POST</strong>!) for an API that we receive Data from. 
  The service offering the API logs Errors that show that the Cloud Function responds with:</p>
  
  <pre><code>500 Server Error
  Error: Server Error
  The server encountered an error and could not complete your request.
  Please try again in 30 seconds.
  </code></pre>
  
  <p>I appended a Screenshot ([1]) as well as a beautified version of the html ([2]) of the whole response to this question.</p>
  
  <p>When this behaviour occurred, I was submitting a maximum of 350 requests to the API at once. The postback-calls are spread over several minutes (because the API takes longer for some input than for others), so it should not be a problem of rates/quotas/limits...</p>
  
  <p>The Firebase Cloud function logs are completely empty regarding this behaviour (this is what confuses me the most). They only show the successful callbacks (same function, same data!). Some people on SO and other forums were pointing to the Google Cloud Logs, but I could not find any more information there than I did on the Firebase Cloud Functions Logs.</p>
  
  <p>Thank you for your time and for any help you can provide!</p>
  
  <p>My package.json:</p>
  
  <pre><code>{
    "name": "functions",
    "version": "1.0.0",
    "scripts": {
      "lint": "tslint --project tsconfig.json",
      "build": "tsc",
      "serve": "npm run build &amp;&amp; firebase serve --only functions",
      "shell": "npm run build &amp;&amp; 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
  }
  </code></pre>
  
  <p>The Cloud Function in a simplified version:</p>
  
  <pre><code>const scrapeCallbackDFS_v2 = async (request, response) =&gt; {
    console.log('resultsCallbackDFS() called ...')
  
    if (
      request.method === 'POST' &amp;&amp;
      request.body &amp;&amp;
      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
    }
  }
  
  </code></pre>
  
  <p>[1] The logs from the API on the callback-Requests:
  <img src="https://i.stack.imgur.com/E5V8F.jpg" alt="Logs from the API"></p>
  
  <p>[2] beautified Cloud Function Response body to the postback-Request:</p>
  
  <pre><code>"server response":"HTTP\/1.1 100 Continue
  &lt;br \/&gt;
  &lt;br \/&gt;HTTP\/1.1 500 Internal Server Error
  &lt;br \/&gt;X-Cloud-Trace-Context: 95a8809b1fc9d9313ccc534fb0c61636
  &lt;br \/&gt;Date: Mon, 08 Jun 2020 17:35:17 GMT
  &lt;br \/&gt;Content-Type: text\/html; charset=UTF-8
  &lt;br \/&gt;Server: Google Frontend
  &lt;br \/&gt;Content-Length: 323
  &lt;br \/&gt;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\"
  &lt;br \/&gt;
  &lt;br \/&gt;
  &lt;br \/&gt;\n
  &lt;html&gt;
  
      &lt;head&gt;
          &lt;br \/&gt;\n
          &lt;meta http-equiv=\ "content-type\" content=\ "text\/html;charset=utf-8\"&gt;
          &lt;br \/&gt;\n
          &lt;title&gt;500 Server Error&lt;\/title&gt;
          &lt;br \/&gt;\n
      &lt;\/head&gt;
      &lt;br \/&gt;\n
  
      &lt;body text=#000000 bgcolor=#ffffff&gt;
          &lt;br \/&gt;\n
          &lt;h1&gt;Error: Server Error&lt;\/h1&gt;
          &lt;br \/&gt;\n
          &lt;h2&gt;The server encountered an error and could not complete your request.
          &lt;p&gt;Please try again in 30 seconds.&lt;\/h2&gt;
          &lt;br \/&gt;\n
          &lt;h2&gt;&lt;\/h2&gt;
          &lt;br \/&gt;\n
      &lt;\/body&gt;
  &lt;\/html&gt;"
  </code></pre>