Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

remove promise.all from closeDatabaseHelper

Maidul Islamb1d16cab39fd
diff --git a/backend/src/helpers/database.ts b/backend/src/helpers/database.ts
index 4780be346d..611e941f58 100644
--- a/backend/src/helpers/database.ts
+++ b/backend/src/helpers/database.ts
@@ -14,7 +14,7 @@ export const initDatabaseHelper = async ({
}) => {
try {
await mongoose.connect(mongoURL);
-
+
// allow empty strings to pass the required validator
mongoose.Schema.Types.String.checkRequired(v => typeof v === "string");
@@ -31,14 +31,10 @@ export const initDatabaseHelper = async ({
* Close database conection
*/
export const closeDatabaseHelper = async () => {
- return Promise.all([
- new Promise((resolve) => {
- if (mongoose.connection && mongoose.connection.readyState == 1) {
- mongoose.connection.close()
- .then(() => resolve("Database connection closed"));
- } else {
- resolve("Database connection already closed");
- }
- }),
- ]);
-}
\ No newline at end of file
+ if (mongoose.connection && mongoose.connection.readyState === 1) {
+ await mongoose.connection.close();
+ return "Database connection closed";
+ } else {
+ return "Database connection already closed";
+ }
+};
\ No newline at end of file