@@ -59,23 +59,29 @@ class ThinConnectionImpl extends ConnectionImpl {
59
59
* @return {Promise }
60
60
*/
61
61
async close ( ) {
62
- if ( this . _protocol . txnInProgress ) {
63
- await this . rollback ( ) ;
64
- }
65
- this . _protocol . callTimeout = 0 ; // not applicable for close
66
- if ( this . _drcpEnabled ) {
67
- await this . _sessRelease ( ) ;
68
- this . _drcpEstablishSession = true ;
69
- }
62
+ try {
63
+ if ( this . _protocol . txnInProgress ) {
64
+ await this . rollback ( ) ;
65
+ }
66
+ this . _protocol . callTimeout = 0 ; // not applicable for close
67
+ if ( this . _drcpEnabled ) {
68
+ await this . _sessRelease ( ) ;
69
+ this . _drcpEstablishSession = true ;
70
+ }
70
71
71
- if ( this . _pool && ! this . _dropSess ) {
72
- await this . _pool . release ( this ) ;
73
- } else {
74
- if ( ! this . _drcpEnabled ) {
75
- const message = new messages . LogOffMessage ( this ) ;
76
- await this . _protocol . _processMessage ( message ) ;
72
+ if ( this . _pool && ! this . _dropSess ) {
73
+ await this . _pool . release ( this ) ;
74
+ } else {
75
+ if ( ! this . _drcpEnabled ) {
76
+ const message = new messages . LogOffMessage ( this ) ;
77
+ await this . _protocol . _processMessage ( message ) ;
78
+ }
79
+ this . nscon . disconnect ( ) ;
77
80
}
78
- this . nscon . disconnect ( ) ;
81
+ } catch ( err ) {
82
+ // immediate close of open socket on failure
83
+ // exception won't be thrown to user
84
+ this . nscon . disconnect ( sqlNetConstants . NSFIMM ) ;
79
85
}
80
86
}
81
87
0 commit comments