Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
paula-stacho committed Nov 4, 2024
1 parent 618a683 commit c170975
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions packages/compass-global-writes/src/store/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,9 @@ export type RootState = {
| ShardingStatuses.UNSHARDED
| ShardingStatuses.SUBMITTING_FOR_SHARDING
| ShardingStatuses.CANCELLING_SHARDING;
/**
* note: shardKey might exist even for unsharded.
* if the collection was sharded previously and then unmanaged
*/
shardKey?: ShardKey;
// shardKey might exist if the collection was sharded before
// and then unmanaged
shardingError?: never;
pollingTimeout?: never;
}
Expand Down Expand Up @@ -487,14 +485,29 @@ const reducer: Reducer<RootState, Action> = (state = initialState, action) => {
) &&
(state.status === ShardingStatuses.CANCELLING_SHARDING ||
state.status === ShardingStatuses.SHARDING_ERROR ||
state.status === ShardingStatuses.CANCELLING_SHARDING_ERROR)
state.status === ShardingStatuses.CANCELLING_SHARDING_ERROR) &&
// the error might come before the cancel request was processed
!state.shardKey
) {
return {
...state,
status: ShardingStatuses.UNSHARDED,
shardingError: undefined,
};
}

if (
isAction<CancellingShardingFinishedAction>(
action,
GlobalWritesActionTypes.CancellingShardingFinished
) &&
state.status === ShardingStatuses.CANCELLING_SHARDING &&
state.shardKey
) {
return {
...state,
status: state.shardKey
? ShardingStatuses.INCOMPLETE_SHARDING_SETUP
: ShardingStatuses.UNSHARDED,
shardKey: state.shardKey,
status: ShardingStatuses.INCOMPLETE_SHARDING_SETUP,
shardingError: undefined,
};
}
Expand Down

0 comments on commit c170975

Please sign in to comment.