@@ -1355,7 +1355,6 @@ class ServiceBroker {
1355
1355
if ( opts . groups && ! Array . isArray ( opts . groups ) ) opts . groups = [ opts . groups ] ;
1356
1356
1357
1357
const promises = [ ] ;
1358
- const localHandlers = [ ] ;
1359
1358
1360
1359
const ctx = this . ContextFactory . create ( this , null , payload , opts ) ;
1361
1360
ctx . eventName = eventName ;
@@ -1385,7 +1384,7 @@ class ServiceBroker {
1385
1384
if ( ep . id === this . nodeID ) {
1386
1385
// Local service, call handler
1387
1386
const newCtx = ctx . copy ( ep ) ;
1388
- localHandlers . push ( this . registry . events . callEventHandler ( newCtx ) ) ;
1387
+ promises . push ( this . registry . events . callEventHandler ( newCtx ) ) ;
1389
1388
} else {
1390
1389
// Remote service
1391
1390
const e = groupedEP [ ep . id ] ;
@@ -1407,20 +1406,6 @@ class ServiceBroker {
1407
1406
} ) ;
1408
1407
}
1409
1408
1410
- // invoke local handlers
1411
- setImmediate ( ( ) =>
1412
- Promise . allSettled ( localHandlers ) . then ( results => {
1413
- results
1414
- . filter ( r => r . status === "rejected" )
1415
- . forEach ( ( { reason : error } ) =>
1416
- this . broadcastLocal ( "$broker.error" , {
1417
- error,
1418
- module : "broker" ,
1419
- type : C . FAILED_HANDLER_BALANCED_EVENT
1420
- } )
1421
- ) ;
1422
- } )
1423
- ) ;
1424
1409
return this . Promise . all ( promises ) ;
1425
1410
} else if ( this . transit ) {
1426
1411
// Disabled balancer case
@@ -1503,19 +1488,7 @@ class ServiceBroker {
1503
1488
}
1504
1489
1505
1490
// Send to local services
1506
- setImmediate ( ( ) =>
1507
- this . Promise . resolve ( )
1508
- . then ( ( ) => this . broadcastLocal ( eventName , payload , opts ) )
1509
- . catch ( error =>
1510
- this . broadcastLocal ( "$broker.error" , {
1511
- error,
1512
- module : "broker" ,
1513
- type : C . FAILED_HANDLER_BROADCAST_EVENT
1514
- } )
1515
- )
1516
- // catch unresolved error
1517
- . catch ( err => this . logger . error ( err ) )
1518
- ) ;
1491
+ promises . push ( this . broadcastLocal ( eventName , payload , opts ) ) ;
1519
1492
1520
1493
return this . Promise . all ( promises ) ;
1521
1494
}
0 commit comments