File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
neo4j-driver-deno/lib/bolt-connection/channel/node Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,9 @@ export default class NodeChannel {
290
290
'and that you have compatible encryption settings both on Neo4j server and driver. ' +
291
291
'Note that the default encryption setting has changed in Neo4j 4.0.'
292
292
if ( err . message ) msg += ' Caused by: ' + err . message
293
+ if ( this . _conn . destroyed ) {
294
+ this . _open = false
295
+ }
293
296
this . _error = newError ( msg , this . _connectionErrorCode )
294
297
if ( this . onerror ) {
295
298
this . onerror ( this . _error )
Original file line number Diff line number Diff line change @@ -222,6 +222,32 @@ describe('NodeChannel', () => {
222
222
} )
223
223
} )
224
224
} )
225
+
226
+ describe ( '._HandleConnectionError()' , ( ) => {
227
+ it ( 'should set open false if connection error on destroyed socket' , ( ) => {
228
+ const address = ServerAddress . fromUrl ( 'bolt://localhost:9999' )
229
+ const channelConfig = new ChannelConfig ( address , { } , SERVICE_UNAVAILABLE )
230
+ const channel = new NodeChannel ( channelConfig )
231
+
232
+ channel . _handleConnectionError ( newError ( 'mock error' ,
233
+ SERVICE_UNAVAILABLE ) )
234
+
235
+ return expect ( channel . _open ) . toBe ( true )
236
+ } )
237
+
238
+ it ( 'should not set open false if connection error on not destroyed socket' , ( ) => {
239
+ const address = ServerAddress . fromUrl ( 'bolt://localhost:9999' )
240
+ const channelConfig = new ChannelConfig ( address , { } , SERVICE_UNAVAILABLE )
241
+ const channel = new NodeChannel ( channelConfig )
242
+
243
+ channel . _conn . destroyed = true
244
+
245
+ channel . _handleConnectionError ( newError ( 'mock error' ,
246
+ SERVICE_UNAVAILABLE ) )
247
+
248
+ return expect ( channel . _open ) . toBe ( false )
249
+ } )
250
+ } )
225
251
} )
226
252
227
253
function createMockedChannel ( connected , config = { connectionTimeout : 30000 } ) {
Original file line number Diff line number Diff line change @@ -290,6 +290,9 @@ export default class NodeChannel {
290
290
'and that you have compatible encryption settings both on Neo4j server and driver. ' +
291
291
'Note that the default encryption setting has changed in Neo4j 4.0.'
292
292
if ( err . message ) msg += ' Caused by: ' + err . message
293
+ if ( this . _conn . destroyed ) {
294
+ this . _open = false
295
+ }
293
296
this . _error = newError ( msg , this . _connectionErrorCode )
294
297
if ( this . onerror ) {
295
298
this . onerror ( this . _error )
You can’t perform that action at this time.
0 commit comments