I'm using the migrate module directly (instead of the CLI) in jest test setups and teardowns (up on setup, down on teardown), and jest was hanging after the down migrations ran.
I noticed that migrateUp and migrateDown never close their connections after executing.
After adding the following finally blocks to each usage, jest stopped hanging, and its process was able to exit cleanly:
.finally(function () {
return connection.close();
});
I'm pretty sure finally isn't supported everywhere yet, but the same can be accomplished via including the same in both a then and a catch. EDIT: actually, it's using the promises returned by rethink, which are bluebird promises (and thus, support finally).
I'm using the migrate module directly (instead of the CLI) in jest test setups and teardowns (up on setup, down on teardown), and jest was hanging after the down migrations ran.
I noticed that migrateUp and migrateDown never close their connections after executing.
After adding the following
finallyblocks to each usage, jest stopped hanging, and its process was able to exit cleanly:I'm pretty sure
finallyisn't supported everywhere yet, but the same can be accomplished via including the same in both athenand acatch. EDIT: actually, it's using the promises returned by rethink, which are bluebird promises (and thus, supportfinally).