Bit.io randomly terminating connecting with node.js

Bit.io randomly terminates connecting with node.js.
When I try to run the following code my node.js works fine for a few minutes but then randomly crashes and gives the error listed at the bottom of this page. I have tried to fix this but I am stuck. Don’t know if it’s a problem with bit.io or with me. Thanks!!

Code:

const { Client } = require('pg');

const client = new Client({
    user: 'procces.env.USER',
    host: 'db.bit.io',
    database: 'procces.env.DATABASE',
    password: 'procces.env.PASSWORD',
    port: 5432,
    ssl: true,
});
client.connect();

client.query('SELECT * FROM "HPI_AT_state" limit 10;', (err, res) => {
    console.table(res.rows);
})

Error:

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: Connection terminated unexpectedly
    at Connection.<anonymous> (node_modules/pg/lib/client.js:132:73)
    at Object.onceWrapper (node:events:627:28)
    at Connection.emit (node:events:513:28)
    at TLSSocket.<anonymous> (node_modules/pg/lib/connection.js:107:12)
    at TLSSocket.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Emitted 'error' event on Client instance at:
    at Client._handleErrorEvent (node_modules/pg/lib/client.js:319:10)
    at Connection.<anonymous> (node_modules/pg/lib/client.js:149:16)
    at Object.onceWrapper (node:events:627:28)
    [... lines matching original stack trace ...]
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)