File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,15 @@ class Session {
87
87
* @return
88
88
*/
89
89
close ( cb = ( ( ) => null ) ) {
90
- this . _onClose ( cb ) ;
90
+ if ( this . _onClose ) {
91
+ try {
92
+ this . _onClose ( cb ) ;
93
+ } finally {
94
+ this . _onClose = null ;
95
+ }
96
+ } else {
97
+ cb ( ) ;
98
+ }
91
99
}
92
100
}
93
101
Original file line number Diff line number Diff line change 19
19
20
20
var neo4j = require ( "../../lib/v1" ) ;
21
21
var StatementType = require ( "../../lib/v1/result-summary" ) . statementType ;
22
+ var Session = require ( "../../lib/v1/session" ) ;
22
23
23
24
describe ( 'session' , function ( ) {
24
25
@@ -35,6 +36,18 @@ describe('session', function() {
35
36
driver . close ( ) ;
36
37
} ) ;
37
38
39
+ it ( 'close should be idempotent ' , function ( ) {
40
+ // Given
41
+ var counter = 0 ;
42
+ var _session = new Session ( null , function ( ) {
43
+ counter ++ ;
44
+ } ) ;
45
+ _session . close ( ) ;
46
+ expect ( counter ) . toBe ( 1 ) ;
47
+ _session . close ( ) ;
48
+ expect ( counter ) . toBe ( 1 ) ;
49
+ } )
50
+
38
51
it ( 'should expose basic run/subscribe ' , function ( done ) {
39
52
// Given
40
53
You can’t perform that action at this time.
0 commit comments