File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ module.exports = function (RED) {
66
77 var sessions = [ ]
88 var readySessionList = [ ]
9+ const SESSION_TIMEOUT_MS = 4000 ; // 4 seconds of inactivity
910
1011 node . server = RED . nodes . getNode ( config . server )
1112
@@ -38,6 +39,10 @@ module.exports = function (RED) {
3839 database : msg . database || config . database || 'neo4j'
3940 } ) ;
4041
42+ if ( boltSession . inactivityTimeout ) {
43+ clearTimeout ( boltSession . inactivityTimeout ) ;
44+ }
45+
4146 let params = null
4247 if ( typeof ( msg . params ) === 'string' ) {
4348 params = JSON . parse ( msg . params )
@@ -119,7 +124,14 @@ module.exports = function (RED) {
119124 . catch ( err => {
120125 node . error ( err , msg ) ;
121126 } ) . finally ( ( ) => {
127+ // Return the session to the ready pool and set an inactivity timeout
122128 readySessionList . push ( readySession )
129+ boltSession . inactivityTimeout = setTimeout ( ( ) => {
130+ // Close the session if not used within the timeout period
131+ boltSession . close ( ) ;
132+ sessions [ readySession ] = null ; // Remove from the session pool
133+ //console.log(`Session ${readySession} closed due to inactivity.`);
134+ } , SESSION_TIMEOUT_MS ) ;
123135 } )
124136 } else {
125137 // no sessions available, send the message out on the third port for further processing bty caller
Original file line number Diff line number Diff line change 3737 "engines" : {
3838 "node" : " >=7.4.0"
3939 },
40- "version" : " 2.5.2 "
40+ "version" : " 2.5.3 "
4141}
You can’t perform that action at this time.
0 commit comments