diff --git a/apps/api/src/config/env.validators.ts b/apps/api/src/config/env.validators.ts index c69013e775a5..c85c1028c440 100644 --- a/apps/api/src/config/env.validators.ts +++ b/apps/api/src/config/env.validators.ts @@ -28,6 +28,7 @@ export const envValidators = { MONGO_URL: str(), MONGO_MIN_POOL_SIZE: num({ default: 10 }), MONGO_MAX_POOL_SIZE: num({ default: 500 }), + MONGO_MAX_IDLE_TIME_IN_MS: num({ default: 1000 * 30 }), NOVU_API_KEY: str({ default: '' }), STORE_ENCRYPTION_KEY: str(), NEW_RELIC_APP_NAME: str({ default: '' }), diff --git a/apps/worker/src/config/env.validators.ts b/apps/worker/src/config/env.validators.ts index 100ff2b31cef..2c288648131a 100644 --- a/apps/worker/src/config/env.validators.ts +++ b/apps/worker/src/config/env.validators.ts @@ -54,6 +54,7 @@ export const envValidators = { MONGO_URL: str(), MONGO_MIN_POOL_SIZE: num({ default: 10 }), MONGO_MAX_POOL_SIZE: num({ default: 500 }), + MONGO_MAX_IDLE_TIME_IN_MS: num({ default: 1000 * 30 }), SEGMENT_TOKEN: str({ default: undefined }), LAUNCH_DARKLY_SDK_KEY: str({ default: undefined }), STRIPE_API_KEY: str({ default: undefined }), diff --git a/libs/dal/src/dal.service.ts b/libs/dal/src/dal.service.ts index 2a741aca0ab6..ed1c5bfd6e0d 100644 --- a/libs/dal/src/dal.service.ts +++ b/libs/dal/src/dal.service.ts @@ -3,7 +3,7 @@ import mongoose, { Connection, ConnectOptions } from 'mongoose'; export const baseConfig: ConnectOptions = { // AUTO_CREATE_INDEXES is deprecated, use MONGO_AUTO_CREATE_INDEXES autoIndex: process.env.AUTO_CREATE_INDEXES === 'true' || process.env.MONGO_AUTO_CREATE_INDEXES === 'true', - maxIdleTimeMS: process.env.MONGO_MAX_IDLE_TIME_IN_MS ? Number(process.env.MONGO_MAX_IDLE_TIME_IN_MS) : 1000 * 60, + maxIdleTimeMS: process.env.MONGO_MAX_IDLE_TIME_IN_MS ? Number(process.env.MONGO_MAX_IDLE_TIME_IN_MS) : 1000 * 30, maxPoolSize: process.env.MONGO_MAX_POOL_SIZE ? Number(process.env.MONGO_MAX_POOL_SIZE) : 50, minPoolSize: process.env.MONGO_MIN_POOL_SIZE ? Number(process.env.MONGO_MIN_POOL_SIZE) : 10, };