Skip to content

Commit c170975

Browse files
committed
fix
1 parent 618a683 commit c170975

File tree

1 file changed

+21
-8
lines changed
  • packages/compass-global-writes/src/store

1 file changed

+21
-8
lines changed

packages/compass-global-writes/src/store/reducer.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)