File tree 1 file changed +14
-14
lines changed
1 file changed +14
-14
lines changed Original file line number Diff line number Diff line change 9
9
Logger ,
10
10
} from '@nestjs/common' ;
11
11
import { ModuleRef } from '@nestjs/core' ;
12
- import { defer } from 'rxjs' ;
12
+ import { defer , of } from 'rxjs' ;
13
13
import {
14
14
Connection ,
15
15
ConnectionOptions ,
@@ -175,22 +175,22 @@ export class TypeOrmCoreModule implements OnApplicationShutdown {
175
175
options : TypeOrmModuleOptions ,
176
176
connectionFactory ?: TypeOrmConnectionFactory ,
177
177
) : Promise < Connection > {
178
- try {
179
- if ( options . keepConnectionAlive ) {
180
- const connectionName = getConnectionName ( options as ConnectionOptions ) ;
181
- const manager = getConnectionManager ( ) ;
182
- if ( manager . has ( connectionName ) ) {
183
- const connection = manager . get ( connectionName ) ;
184
- if ( connection . isConnected ) {
185
- return connection ;
186
- }
187
- }
188
- }
189
- } catch { }
190
-
191
178
const connectionToken = getConnectionName ( options as ConnectionOptions ) ;
192
179
const createTypeormConnection = connectionFactory ?? createConnection ;
193
180
return await defer ( ( ) => {
181
+ try {
182
+ if ( options . keepConnectionAlive ) {
183
+ const connectionName = getConnectionName ( options as ConnectionOptions ) ;
184
+ const manager = getConnectionManager ( ) ;
185
+ if ( manager . has ( connectionName ) ) {
186
+ const connection = manager . get ( connectionName ) ;
187
+ if ( connection . isConnected ) {
188
+ return of ( connection ) ;
189
+ }
190
+ }
191
+ }
192
+ } catch { }
193
+
194
194
if ( ! options . type ) {
195
195
return createTypeormConnection ( ) ;
196
196
}
You can’t perform that action at this time.
0 commit comments