Skip to content
Igor Savin edited this page Nov 12, 2018 · 2 revisions

Node instance doesn't stop after using knex

Make sure to close knex instance after execution to avoid Node process hanging due to open connections:

async function migrate() {
  try {
      await knex.migrate.latest({/**config**/})
    }
  } catch (e) {
    process.exit(1)
  } finally {
    try {
      knex.destroy()
    } catch (e) {}
  }
}

migrate()
Clone this wiki locally