@@ -319,15 +319,16 @@ internal final class ActorShell<Message>: ActorContext<Message>, AbstractActor {
319319 switch circumstances {
320320 // escalation takes precedence over death watch in terms of how we report errors
321321 case . escalating( let failure) :
322+ // we only populate `escalation` if the child is escalating
322323 let terminated = Signals . ChildTerminated ( address: ref. address, escalation: failure)
323- try self . interpretChildTerminatedSignal ( who: ref, terminated: terminated, escalation : true )
324+ try self . interpretChildTerminatedSignal ( who: ref, terminated: terminated)
324325
325326 case . stopped:
326327 let terminated = Signals . ChildTerminated ( address: ref. address, escalation: nil )
327- try self . interpretChildTerminatedSignal ( who: ref, terminated: terminated, escalation : false )
328- case . failed( let failure ) :
329- let terminated = Signals . ChildTerminated ( address: ref. address, escalation: failure )
330- try self . interpretChildTerminatedSignal ( who: ref, terminated: terminated, escalation : false )
328+ try self . interpretChildTerminatedSignal ( who: ref, terminated: terminated)
329+ case . failed:
330+ let terminated = Signals . ChildTerminated ( address: ref. address, escalation: nil )
331+ try self . interpretChildTerminatedSignal ( who: ref, terminated: terminated)
331332 }
332333
333334 case . nodeTerminated( let remoteNode) :
@@ -396,10 +397,7 @@ internal final class ActorShell<Message>: ActorContext<Message>, AbstractActor {
396397 internal func fail( _ error: Error ) {
397398 self . _myCell. mailbox. setFailed ( )
398399 self . behavior = self . behavior. fail ( cause: . error( error) )
399- // TODO: we could handle here "wait for children to terminate"
400400
401- // we only finishTerminating() here and not right away in message handling in order to give the Mailbox
402- // a chance to react to the problem as well; I.e. 1) we throw 2) mailbox sets terminating 3) we get fail() 4) we REALLY terminate
403401 switch error {
404402 case DeathPactError . unhandledDeathPact( _, _, let message) :
405403 self . log. error ( " \( message) " ) // TODO: configurable logging? in props?
@@ -530,6 +528,8 @@ internal final class ActorShell<Message>: ActorContext<Message>, AbstractActor {
530528
531529 // become stopped, if not already
532530 switch self . behavior. underlying {
531+ case . failed( _, let failure) :
532+ self . behavior = . stop( reason: . failure( failure) )
533533 case . stop( _, let reason) :
534534 self . behavior = . stop( reason: reason)
535535 default :
@@ -727,7 +727,7 @@ extension ActorShell {
727727 }
728728
729729 @inlinable
730- internal func interpretChildTerminatedSignal( who terminatedRef: AddressableActorRef , terminated: Signals . ChildTerminated , escalation : Bool ) throws {
730+ internal func interpretChildTerminatedSignal( who terminatedRef: AddressableActorRef , terminated: Signals . ChildTerminated ) throws {
731731 #if SACT_TRACE_ACTOR_SHELL
732732 self . log. info ( " Received \( terminated) " )
733733 #endif
0 commit comments