Skip to content

Commit 008757a

Browse files
committed
fix(mongooose-core-module): wait for connection in forRootAsync
Currently the connection is only awaited if using the forRoot method. Add this behavior to the forRootAsync as well.
1 parent 683706e commit 008757a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/mongoose-core.module.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ export class MongooseCoreModule implements OnApplicationShutdown {
9797
return await lastValueFrom(
9898
defer(async () =>
9999
mongooseConnectionFactory(
100-
mongoose.createConnection(
101-
mongooseModuleOptions.uri as string,
102-
mongooseOptions,
103-
),
100+
await mongoose
101+
.createConnection(
102+
mongooseModuleOptions.uri as string,
103+
mongooseOptions,
104+
)
105+
.asPromise(),
104106
mongooseConnectionName,
105107
),
106108
).pipe(

0 commit comments

Comments
 (0)