Skip to content

Commit

Permalink
Discard invalid tasks (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
DZakh authored Dec 17, 2024
1 parent 5605da1 commit 4133be6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,7 @@ let invalidatedActionReducer = (state: t, action: action) =>
| ({rollbackState: RollingBack(_)}, EventBatchProcessed(_)) =>
Logging.warn("Finished processing batch before rollback, actioning rollback")
({...state, currentlyProcessingBatch: false}, [Rollback])
| (_, ErrorExit(_)) => actionReducer(state, action)
| _ =>
Logging.warn("Invalidated action discarded")
(state, [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ module MakeManager = (S: State) => {
and dispatchTask = (self, task: S.task) => {
let stateId = self.state->S.getId
Js.Global.setTimeout(() => {
S.taskReducer(self.state, task, ~dispatchAction=action =>
dispatchAction(~stateId, self, action)
)->ignore
if stateId !== self.state->S.getId {
Logging.warn("Invalidated task discarded")
} else {
S.taskReducer(self.state, task, ~dispatchAction=action =>
dispatchAction(~stateId, self, action)
)->ignore
}
}, 0)->ignore
}

Expand Down

0 comments on commit 4133be6

Please sign in to comment.