title: Why is UnhandledPromiseRejectionWarning only appearing in production (Google Cloud Run)?
body: <p>I am having a very hard time trying to solve a few functions that work perfectly fine on my laptop development environment (even if I run it with NODE_ENV=production) but when I deploy it to Google Cloud Run I get errors such as</p>
  <pre><code>Default
  2021-12-15T12:16:35.016406Z at TCP.done (_tls_wrap.js:564:7)
  Default
  2021-12-15T12:16:35.016414Z(Use `node --trace-warnings ...` to show where the warning was created)
  Default
  2021-12-15T12:16:35.016426Z(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
  Default
  2021-12-15T12:16:35.116284Z(node:1) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  Default
  2021-12-15T12:16:35.116931Z(node:1) UnhandledPromiseRejectionWarning: Error: socket hang up
  Default
  2021-12-15T12:16:35.116954Z at connResetException (internal/errors.js:639:14)
  Default
  2021-12-15T12:16:35.116969Z at TLSSocket.socketCloseListener (_http_client.js:449:25)
  Default
  2021-12-15T12:16:35.116979Z at TLSSocket.emit (events.js:412:35)
  Default
  2021-12-15T12:16:35.116989Z at net.js:686:12
  Default
  2021-12-15T12:16:35.116999Z at TCP.done (_tls_wrap.js:564:7)
  </code></pre>
  <p>causing my script to halt. In my local version it continues without stopping. It is very frustrating as I need to upload the code to Cloud Run all the time in order to test my code. I am testing it blindly as the errors do not appear in my development version.</p>
  <p>I am quite new to Node.js and are constantly having a hard time with .then(), chaining .then(), promises, using resolve() so the code is likely to be wrong.</p>
  <p>My questions here:</p>
  <ol>
  <li>Why is this error only appearing on Cloud Run?</li>
  <li>How can I configure my local computer the same way so it shows the same warnings and errors - so I can troubleshoot this?</li>
  </ol>
  <hr />
  <p>My code (simplified):</p>
  <pre><code>function createOrUpdateSpotterData(data) {
  
     // NOTE: Data comes from API and not from DB, thus no info such as twitter_status
     // TODO: Separate into a create or update, in order to not check twitter ID every time.
     return new Promise( async function (resolve) { 
        var twitterId = await twitterApi.getTwitterIdFromUsername(cleanedUsername)
        data['twitter_numeric'] = twitterId    
        resolve(data)
  
     }).then( (data) =&gt; {
        db.collection('spotters').doc(data.marker).set(data) 
     }).catch( (error) =&gt; { console.log(error) })
  }
  
  async function updateSpottersJsonToDb() {
     console.log(&quot;&gt; updateSpottersJsonToDb&quot;)
     return new Promise( (resolve, reject) =&gt; {
        readStorageData(remote_files['spotters'])
           .then( async (spotterListJson) =&gt; {
              var spotterList = JSON.parse(spotterListJson)       
              await spotterList.forEach((spotter) =&gt; {
                 createOrUpdateSpotterData(spotter)
              })                         
           })
           .then(() =&gt; { 
              resolve() 
           })
           .catch((error) =&gt; {console.error(error)})
     }).catch((error) =&gt; {console.error(error)})
  </code></pre>