@@ -662,8 +662,9 @@ export class Activator implements ActivationHandler {
662
662
// These are caught elsewhere and fail the corresponding activation.
663
663
const doUpdateImpl = async ( ) => {
664
664
let input : UpdateInput ;
665
+ const entry = this . updateHandlers . get ( name ) ;
665
666
try {
666
- if ( runValidator && this . updateHandlers . get ( name ) ?. validator ) {
667
+ if ( runValidator && entry ?. validator ) {
667
668
const validate = composeInterceptors (
668
669
this . interceptors . inbound ,
669
670
'validateUpdate' ,
@@ -676,15 +677,12 @@ export class Activator implements ActivationHandler {
676
677
this . rejectUpdate ( protocolInstanceId , error ) ;
677
678
return ;
678
679
}
679
-
680
- const entry = this . updateHandlers . get ( name ) ;
680
+ this . acceptUpdate ( protocolInstanceId ) ;
681
+ const execute = composeInterceptors ( this . interceptors . inbound , 'handleUpdate' , this . updateNextHandler . bind ( this ) ) ;
681
682
if ( ! entry ) {
682
683
return Promise . reject ( new IllegalStateError ( `No registered update handler for update: ${ name } ` ) ) ;
683
684
}
684
685
const { unfinishedPolicy } = entry ;
685
-
686
- const execute = composeInterceptors ( this . interceptors . inbound , 'handleUpdate' , this . updateNextHandler . bind ( this ) ) ;
687
- this . acceptUpdate ( protocolInstanceId ) ;
688
686
this . inProgressUpdates . set ( updateId , { name, unfinishedPolicy, id : updateId } ) ;
689
687
const res = execute ( input )
690
688
. then ( ( result ) => this . completeUpdate ( protocolInstanceId , result ) )
@@ -703,11 +701,7 @@ export class Activator implements ActivationHandler {
703
701
}
704
702
705
703
protected async updateNextHandler ( { name, args } : UpdateInput ) : Promise < unknown > {
706
- const entry = this . updateHandlers . get ( name ) ;
707
- if ( ! entry ) {
708
- return Promise . reject ( new IllegalStateError ( `No registered update handler for update: ${ name } ` ) ) ;
709
- }
710
- const { handler } = entry ;
704
+ const { handler } = this . updateHandlers . get ( name ) ! ;
711
705
return await handler ( ...args ) ;
712
706
}
713
707
0 commit comments