File tree Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Expand file tree Collapse file tree 3 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -178,12 +178,16 @@ class ConnectionHolder implements ConnectionHolderInterface {
178
178
return this . _connectionPromise
179
179
}
180
180
181
+ < << << << HEAD
181
182
close ( ) : Promise < null | Connection > {
183
+ = === ===
184
+ close ( hasTx ?: boolean ) : Promise < void | Connection > {
185
+ >>> > >>> Sending reset if there is a tx going on
182
186
if ( this . _referenceCount === 0 ) {
183
187
return this . _connectionPromise
184
188
}
185
189
this . _referenceCount = 0
186
- return this . _releaseConnection ( )
190
+ return this . _releaseConnection ( hasTx )
187
191
}
188
192
189
193
/**
@@ -197,7 +201,7 @@ class ConnectionHolder implements ConnectionHolderInterface {
197
201
this . _connectionPromise = this . _connectionPromise
198
202
. then ( ( connection ?: Connection | null ) => {
199
203
if ( connection != null ) {
200
- if ( connection . isOpen ( ) && connection . hasOngoingObservableRequests ( ) ) {
204
+ if ( connection . isOpen ( ) && ( connection . hasOngoingObservableRequests ( ) || hasTx ) ) {
201
205
return connection
202
206
. resetAndFlush ( )
203
207
. catch ( ignoreError )
Original file line number Diff line number Diff line change @@ -494,8 +494,8 @@ class Session {
494
494
495
495
this . _transactionExecutor . close ( )
496
496
497
- await this . _readConnectionHolder . close ( )
498
- await this . _writeConnectionHolder . close ( )
497
+ await this . _readConnectionHolder . close ( this . _hasTx )
498
+ await this . _writeConnectionHolder . close ( this . _hasTx )
499
499
}
500
500
}
501
501
Original file line number Diff line number Diff line change @@ -196,17 +196,28 @@ describe('session', () => {
196
196
expect ( resetAndFlushSpy ) . toHaveBeenCalledTimes ( 1 )
197
197
} , 70000 )
198
198
199
- it ( 'close should not reset connection if there is not an ongoing request ' , async ( ) => {
199
+ it ( 'close should not reset connection if there is not an ongoing request' , async ( ) => {
200
200
const connection = newFakeConnection ( )
201
201
connection . hasOngoingObservableRequests = ( ) => false
202
202
const resetAndFlushSpy = jest . spyOn ( connection , 'resetAndFlush' )
203
- const session = newSessionWithConnection ( connection )
203
+ const session = newSessionWithConnection ( connection , false )
204
204
205
205
await session . close ( )
206
206
207
207
expect ( resetAndFlushSpy ) . not . toHaveBeenCalled ( )
208
208
} , 70000 )
209
209
210
+ it ( 'close should reset connection if there is not an ongoing request but it has tx running' , async ( ) => {
211
+ const connection = newFakeConnection ( )
212
+ connection . hasOngoingObservableRequests = ( ) => false
213
+ const resetAndFlushSpy = jest . spyOn ( connection , 'resetAndFlush' )
214
+ const session = newSessionWithConnection ( connection )
215
+
216
+ await session . close ( )
217
+
218
+ expect ( resetAndFlushSpy ) . toHaveBeenCalled ( )
219
+ } , 70000 )
220
+
210
221
it ( 'should close transaction executor' , done => {
211
222
const session = newSessionWithConnection ( newFakeConnection ( ) )
212
223
You can’t perform that action at this time.
0 commit comments