@@ -215,11 +215,9 @@ export type RootState = {
215215 | ShardingStatuses . UNSHARDED
216216 | ShardingStatuses . SUBMITTING_FOR_SHARDING
217217 | ShardingStatuses . CANCELLING_SHARDING ;
218- /**
219- * note: shardKey might exist even for unsharded.
220- * if the collection was sharded previously and then unmanaged
221- */
222218 shardKey ?: ShardKey ;
219+ // shardKey might exist if the collection was sharded before
220+ // and then unmanaged
223221 shardingError ?: never ;
224222 pollingTimeout ?: never ;
225223 }
@@ -487,14 +485,29 @@ const reducer: Reducer<RootState, Action> = (state = initialState, action) => {
487485 ) &&
488486 ( state . status === ShardingStatuses . CANCELLING_SHARDING ||
489487 state . status === ShardingStatuses . SHARDING_ERROR ||
490- state . status === ShardingStatuses . CANCELLING_SHARDING_ERROR )
488+ state . status === ShardingStatuses . CANCELLING_SHARDING_ERROR ) &&
491489 // the error might come before the cancel request was processed
490+ ! state . shardKey
491+ ) {
492+ return {
493+ ...state ,
494+ status : ShardingStatuses . UNSHARDED ,
495+ shardingError : undefined ,
496+ } ;
497+ }
498+
499+ if (
500+ isAction < CancellingShardingFinishedAction > (
501+ action ,
502+ GlobalWritesActionTypes . CancellingShardingFinished
503+ ) &&
504+ state . status === ShardingStatuses . CANCELLING_SHARDING &&
505+ state . shardKey
492506 ) {
493507 return {
494508 ...state ,
495- status : state . shardKey
496- ? ShardingStatuses . INCOMPLETE_SHARDING_SETUP
497- : ShardingStatuses . UNSHARDED ,
509+ shardKey : state . shardKey ,
510+ status : ShardingStatuses . INCOMPLETE_SHARDING_SETUP ,
498511 shardingError : undefined ,
499512 } ;
500513 }
0 commit comments