@@ -15,7 +15,7 @@ export class Service {
1515
1616 dispatchRequest ( client : Buffer , ...req : Buffer [ ] ) {
1717 this . requests . push ( [ client , req ] )
18- this . dispatchPending ( )
18+ return this . dispatchPending ( )
1919 }
2020
2121 async dispatchReply ( worker : Buffer , client : Buffer , ...rep : Buffer [ ] ) {
@@ -28,12 +28,15 @@ export class Service {
2828
2929 await this . socket . send ( [ client , null , Header . Client , this . name , ...rep ] )
3030
31- this . dispatchPending ( )
31+ return this . dispatchPending ( )
3232 }
3333
3434 async dispatchPending ( ) {
3535 while ( this . workers . size && this . requests . length ) {
36- const [ key , worker ] = this . workers . entries ( ) . next ( ) . value !
36+ const [ key , worker ] = this . workers . entries ( ) . next ( ) . value as [
37+ string ,
38+ Buffer ,
39+ ]
3740 this . workers . delete ( key )
3841 const [ client , req ] = this . requests . shift ( ) !
3942
@@ -42,6 +45,7 @@ export class Service {
4245 `${ client . toString ( "hex" ) } req -> ${ worker . toString ( "hex" ) } ` ,
4346 )
4447
48+ // eslint-disable-next-line no-await-in-loop
4549 await this . socket . send ( [
4650 worker ,
4751 null ,
@@ -59,14 +63,14 @@ export class Service {
5963 `registered worker ${ worker . toString ( "hex" ) } for '${ this . name } '` ,
6064 )
6165 this . workers . set ( worker . toString ( "hex" ) , worker )
62- this . dispatchPending ( )
66+ return this . dispatchPending ( )
6367 }
6468
6569 deregister ( worker : Buffer ) {
6670 console . log (
6771 `deregistered worker ${ worker . toString ( "hex" ) } for '${ this . name } '` ,
6872 )
6973 this . workers . delete ( worker . toString ( "hex" ) )
70- this . dispatchPending ( )
74+ return this . dispatchPending ( )
7175 }
7276}
0 commit comments