@@ -615,6 +615,8 @@ export class ExpectationManager {
615615 user : `Added just now` ,
616616 tech : `Added ${ Date . now ( ) } ` ,
617617 } ,
618+ // Don't update the package status, since we don't know anything about the package yet.
619+ dontUpdatePackage : true ,
618620 } )
619621 } else {
620622 this . updateTrackedExpStatus ( newTrackedExp , {
@@ -623,6 +625,8 @@ export class ExpectationManager {
623625 user : `Updated just now` ,
624626 tech : `Updated ${ Date . now ( ) } , diff: (${ diff ( existingtrackedExp . exp , exp ) } )` ,
625627 } ,
628+ // Don't update the package status, since the package likely hasn't changed:
629+ dontUpdatePackage : true ,
626630 } )
627631 }
628632 } else if ( difference === 'minor' ) {
@@ -691,6 +695,8 @@ export class ExpectationManager {
691695 user : 'Restarted by user' ,
692696 tech : `Restarted by user` ,
693697 } ,
698+ // Don't update the package status, since the package likely hasn't changed:
699+ dontUpdatePackage : true ,
694700 } )
695701 trackedExp . lastEvaluationTime = 0 // To rerun ASAP
696702 }
@@ -714,6 +720,8 @@ export class ExpectationManager {
714720 user : 'Aborted by user' ,
715721 tech : `Aborted by user` ,
716722 } ,
723+ // Don't update the package status, since the package likely hasn't changed:
724+ dontUpdatePackage : true ,
717725 } )
718726 }
719727 }
@@ -919,12 +927,16 @@ export class ExpectationManager {
919927 user : `${ availableWorkersCount } workers available, about to start...` ,
920928 tech : `Found ${ availableWorkersCount } workers who supports this Expectation` ,
921929 } ,
930+ // Don't update the package status, since we don't know anything about the package yet:
931+ dontUpdatePackage : true ,
922932 } )
923933 trackedExp . session . triggerExpectationAgain = true
924934 } else {
925935 // If we didn't query anyone, just skip ahead to next state without being too verbose:
926936 this . updateTrackedExpStatus ( trackedExp , {
927937 state : ExpectedPackageStatusAPI . WorkStatusState . WAITING ,
938+ // Don't update the package status, since we don't know anything about the package yet:
939+ dontUpdatePackage : true ,
928940 } )
929941 }
930942 } else {
@@ -936,6 +948,8 @@ export class ExpectationManager {
936948 user : `No Workers available (this is likely a configuration issue)` ,
937949 tech : `No Workers available` ,
938950 } ,
951+ // Don't update the package status, since we don't know anything about the package yet:
952+ dontUpdatePackage : true ,
939953 } )
940954 } else {
941955 this . updateTrackedExpStatus ( trackedExp , {
@@ -944,6 +958,8 @@ export class ExpectationManager {
944958 user : `No Workers available (this is likely a configuration issue)` ,
945959 tech : `No Workers queried, ${ Object . keys ( this . workerAgents ) . length } available` ,
946960 } ,
961+ // Don't update the package status, since we don't know anything about the package yet:
962+ dontUpdatePackage : true ,
947963 } )
948964 }
949965 } else {
@@ -955,6 +971,8 @@ export class ExpectationManager {
955971 trackedExp . noAvailableWorkersReason . tech
956972 } ", have asked workers: [${ Object . keys ( trackedExp . queriedWorkers ) . join ( ',' ) } ]`,
957973 } ,
974+ // Don't update the package status, since we don't know anything about the package yet:
975+ dontUpdatePackage : true ,
958976 } )
959977 }
960978 }
@@ -1020,7 +1038,6 @@ export class ExpectationManager {
10201038 error
10211039 ) } "`,
10221040 } ,
1023-
10241041 isError : true ,
10251042 } )
10261043 }
@@ -1106,6 +1123,8 @@ export class ExpectationManager {
11061123 // Restart
11071124 this . updateTrackedExpStatus ( trackedExp , {
11081125 state : ExpectedPackageStatusAPI . WorkStatusState . NEW ,
1126+ // Don't update the package status, since we don't know anything about the package at this point:
1127+ dontUpdatePackage : true ,
11091128 } )
11101129 } else {
11111130 // Do nothing, hopefully some will be available at a later iteration
@@ -1152,7 +1171,7 @@ export class ExpectationManager {
11521171 ) } `,
11531172 } ,
11541173 // Should we se this here?
1155- // dontUpdatePackageStatus : true,
1174+ // dontUpdatePackage : true,
11561175 } )
11571176 }
11581177 } else {
@@ -1212,7 +1231,6 @@ export class ExpectationManager {
12121231 this . updateTrackedExpStatus ( trackedExp , {
12131232 state : ExpectedPackageStatusAPI . WorkStatusState . RESTARTED ,
12141233 reason : removed . reason ,
1215-
12161234 isError : true ,
12171235 } )
12181236 }
@@ -1285,9 +1303,14 @@ export class ExpectationManager {
12851303 status ?: Partial < TrackedExpectation [ 'status' ] > | undefined
12861304 /** Whether the new state is due an error or not */
12871305 isError ?: boolean
1306+ /**
1307+ * If set, the package on packageContainer status won't be updated.
1308+ * This is used to defer updates in situations where we don't really know what the status of the package is.
1309+ * */
1310+ dontUpdatePackage ?: boolean
12881311 }
12891312 ) {
1290- const { state, reason, status, isError } = upd
1313+ const { state, reason, status, isError, dontUpdatePackage } = upd
12911314
12921315 trackedExp . lastEvaluationTime = Date . now ( )
12931316 if ( isError ) trackedExp . lastErrorTime = Date . now ( )
@@ -1339,8 +1362,10 @@ export class ExpectationManager {
13391362 prevStatusReasons : trackedExp . prevStatusReasons ,
13401363 } )
13411364 }
1342- if ( updatedState || updatedReason || updatedStatus ) {
1343- this . updatePackageContainerPackageStatus ( trackedExp , false )
1365+ if ( ! dontUpdatePackage ) {
1366+ if ( updatedState || updatedReason || updatedStatus ) {
1367+ this . updatePackageContainerPackageStatus ( trackedExp , false )
1368+ }
13441369 }
13451370 }
13461371 private updatePackageContainerPackageStatus ( trackedExp : TrackedExpectation , isRemoved : boolean ) {
@@ -1490,11 +1515,15 @@ export class ExpectationManager {
14901515 this . updateTrackedExpStatus ( trackedExp , {
14911516 state : ExpectedPackageStatusAPI . WorkStatusState . NEW ,
14921517 reason : noAssignedWorkerReason ,
1518+ // Don't update the package status, since this means that we don't know anything about the package:
1519+ dontUpdatePackage : true ,
14931520 } )
14941521 } else {
14951522 // only update the reason
14961523 this . updateTrackedExpStatus ( trackedExp , {
14971524 reason : noAssignedWorkerReason ,
1525+ // Don't update the package status, since this means that we don't know anything about the package:
1526+ dontUpdatePackage : true ,
14981527 } )
14991528 }
15001529 }
0 commit comments