title: Functioning Heroku-deployed Twitter bot stills shows Application error?
body: <p>I have a functioning Twitter bot (<a href="https://twitter.com/Sunlight_Bot" rel="nofollow noreferrer">@Sunlight_Bot</a>) deployed on Heroku that stills shows this error:</p>
  
  <p><img src="https://i.imgur.com/WpqkJ3v.png" alt="Heroku error"></p>
  
  <p>The logs show a error H14, which I believe is occuring simply because the dyno is shut down while my bot is waiting (<code>setInterval</code>) between posts, correct?</p>
  
  <pre><code>2019-04-23T22:26:16.989176+00:00 app[api]: Release v81 created by user &lt;user&gt;
  2019-04-23T22:26:16.989176+00:00 app[api]: Deploy ... by user &lt;user&gt;
  2019-04-23T22:26:17.000000+00:00 app[api]: Build succeeded
  2019-04-23T22:26:18.042459+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
  2019-04-23T22:26:18.104139+00:00 heroku[worker.1]: Process exited with status 143
  2019-04-23T22:26:19.664782+00:00 heroku[worker.1]: Starting process with command `node app.js`
  2019-04-23T22:26:20.333252+00:00 heroku[worker.1]: State changed from starting to up
  2019-04-23T22:27:53.987454+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=&lt;host&gt; request_id=&lt;id&gt; fwd="&lt;fwd&gt;" dyno= connect= service= status=503 bytes= protocol=https
  2019-04-23T22:27:54.206902+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=&lt;host&gt; request_id=&lt;id&gt; fwd="&lt;fwd&gt;" dyno= connect= service= status=503 bytes= protocol=https
  </code></pre>
  
  <p><strong>Why is Heroku still showing this Application Error despite the bot apperently functioning? Is this something that I can/should fix?</strong></p>
  
  <p>Here's the code. <code>setInterval</code> calls the <code>tweeter()</code> function once every six hours. The function gets some data from a Heroku PostgreSQL database, formats it, and posts it to Twitter as one or more Tweets.</p>
  
  <pre><code>function tweeter() {
  
      stafferInfo = {};
      tweetString = '';
  
      let pool = new pg.Pool({
          connectionString: process.env.DATABASE_URL,
          ssl: true
      } || config.db);
  
      pool.connect()
  
          .then(client =&gt; {
              pgClient = client;
              return pgClient.query(randomRow)
                  .then(res =&gt; {
                      stafferInfo = res.rows[0];   // (1) GET INFO FROM DB AND SET VARIABLE
                      // console.log(stafferInfo);
  
                  })
                  .catch(err =&gt; console.error('Error executing first psql query', err.stack));
          })
  
          .then(() =&gt; {
              return pgClient.query(updateTweeted) // (2) UPDATE "TWEETED" COUNT
                  .then(res =&gt; {
                      // console.log(res);
                  })
                  .catch(err =&gt; console.error('Error executing second psql query', err.stack));
          })
          .then(() =&gt; {                     // (3) POST TWEET
              tweetString = formatTweet(stafferInfo);
  
              if ((`${tweetString} (data from ProPublica's Trump Town dataset)`).length &lt;= (280)) {
                  tweetString += ` (data from ProPublica's Trump Town dataset)`
              }
              else if (tweetString.length &lt;= 280) {
  
                  console.log(tweetString);
  
                  sendTweet(tweetString);
  
                  if (stafferInfo.linkedin_url) {
                      console.log(formatLinkedIn(stafferInfo));
                      sendTweet(formatLinkedIn(stafferInfo));
                  }
                  if (stafferInfo.resume_document_url) {
                      console.log(formatResume(stafferInfo));
                      sendTweet(formatResume(stafferInfo));
                  }
                  if (stafferInfo.financial_disclosure_url) {
                      console.log(formatFinancialDisclosure(stafferInfo));
                      sendTweet(formatFinancialDisclosure(stafferInfo));
                  }
                  if (stafferInfo.ethics_waiver_url) {
                      console.log(formatEthicsWaiver(stafferInfo));
                      sendTweet(formatEthicsWaiver(stafferInfo));
                  }
              }
              else {
                  console.log(`Tweet is longer than 280 characters: ${tweetString}`);
              }
          })
          .catch(err =&gt; {
              console.error('Error acquiring client: ', err.stack);  // IF ERROR THROW TO CONSOLE
          })
          .finally(() =&gt; {                                // EITHER WAY SHUT DOWN CLIENT &amp; POOL AFTER
              if (pgClient) {
                  pgClient.release();
              }
              pool.end(); // pool shutdown
          });
  }
  
  // tweeter(); // For testing
  
  setInterval(tweeter, 6*60*60*1000);
  </code></pre>