@@ -11,7 +11,6 @@ const { resolvingPromise } = require('../../lib/node/promiseUtils');
1111const  fs  =  require ( 'fs' ) . promises ; 
1212const  path  =  require ( 'path' ) ; 
1313const  dns  =  require ( 'dns' ) ; 
14- const  sleep  =  require ( './sleep' ) ; 
1514const  MockEmailAdapterWithOptions  =  require ( './support/MockEmailAdapterWithOptions' ) ; 
1615
1716// Ensure localhost resolves to ipv4 address first on node v17+ 
@@ -108,18 +107,24 @@ const shutdownServer = async _parseServer => {
108107  _parseServer . server . on ( 'close' ,  ( )  =>  { 
109108    closePromise . resolve ( ) ; 
110109  } ) ; 
111-   _parseServer . handleShutdown ( ) ; 
110+   await  Promise . all ( [ 
111+     _parseServer . config . databaseController . adapter . handleShutdown ( ) , 
112+     _parseServer . liveQueryServer . shutdown ( ) , 
113+   ] ) ; 
114+   _parseServer . server . close ( error  =>  { 
115+     if  ( error )  { 
116+       console . error ( 'Failed to close Parse Server' ,  error ) ; 
117+     } 
118+   } ) ; 
112119  destroyConnections ( ) ; 
113120  await  closePromise ; 
114-   // Connection close events are not immediate on node 10+, so wait a bit 
115-   await  sleep ( 0 ) ; 
116121  expect ( openConnections . size ) . toBe ( 0 ) ; 
122+   parseServer  =  undefined ; 
117123} ; 
118124
119125const  reconfigureServer  =  async  ( changedConfiguration  =  { } )  =>  { 
120126  if  ( parseServer )  { 
121127    await  shutdownServer ( parseServer ) ; 
122-     parseServer  =  undefined ; 
123128    return  reconfigureServer ( changedConfiguration ) ; 
124129  } 
125130  didChangeConfiguration  =  Object . keys ( changedConfiguration ) . length  !==  0 ; 
0 commit comments