File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,13 @@ describe('Reconnection', function() {
7676 server2 . forceShutdown ( ) ;
7777 } ) ;
7878 it ( 'Should end with either OK or UNAVAILABLE when querying a server that is shutting down' , function ( done ) {
79+ let pendingCalls = 0 ;
80+ let testDone = false ;
81+ function maybeDone ( ) {
82+ if ( testDone && pendingCalls === 0 ) {
83+ done ( ) ;
84+ }
85+ } ;
7986 client . unary ( { } , ( err , data ) => {
8087 assert . ifError ( err ) ;
8188 server1 . tryShutdown ( ( ) => {
@@ -84,14 +91,18 @@ describe('Reconnection', function() {
8491 client . unary ( { } , ( err , data ) => {
8592 assert . ifError ( err ) ;
8693 clearInterval ( callInterval ) ;
87- done ( ) ;
94+ testDone = true ;
95+ maybeDone ( ) ;
8896 } ) ;
8997 } ) ;
9098 let callInterval = setInterval ( ( ) => {
99+ pendingCalls += 1 ;
91100 client . unary ( { } , ( err , data ) => {
101+ pendingCalls -= 1 ;
92102 if ( err ) {
93103 assert . strictEqual ( err . code , clientGrpc . status . UNAVAILABLE ) ;
94104 }
105+ maybeDone ( ) ;
95106 } ) ;
96107 } , 0 ) ;
97108 } ) ;
You can’t perform that action at this time.
0 commit comments