From 3776322904a984839c799f481eda8e1740d8f26b Mon Sep 17 00:00:00 2001 From: Alan Cruikshanks Date: Thu, 28 Sep 2023 11:38:08 +0100 Subject: [PATCH] Update Knex config to avoid hanging promises When trying to work with the DB in the tests we were getting ``` Jest did not exit one second after the test run has completed. This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue. ``` Googling led us to [Having trouble running Jest, unhandled Promises](https://github.com/Vincit/objection.js/issues/1015) and [Need to explicit destroy knex in order to stop the script](https://github.com/Vincit/objection.js/issues/534). The second issue included a comment that setting the pool min size to 0 and idleTimeoutMillis to 500 would solve the problem. We tried it and it worked! --- knexfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/knexfile.js b/knexfile.js index b89aeb039b..4109d81af6 100644 --- a/knexfile.js +++ b/knexfile.js @@ -30,6 +30,7 @@ const development = { const test = { ...defaultConfig, + pool: { min: 0, idleTimeoutMillis: 500 }, connection: { ...defaultConnection, database: DatabaseConfig.testDatabase