Skip to content

Commit 950fa76

Browse files
fix(overmind): check parent action execution on async flush to ensure it is needed
1 parent 4e5187d commit 950fa76

File tree

1 file changed

+21
-11
lines changed
  • packages/node_modules/overmind/src

1 file changed

+21
-11
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,13 @@ export class Overmind<ThisConfig extends IConfiguration>
307307
}
308308

309309
if (process.env.NODE_ENV === 'production' && mode.mode === MODE_DEFAULT) {
310-
eventHub.on(EventType.OPERATOR_ASYNC, () => {
311-
proxyStateTree.getMutationTree().flush(true)
310+
eventHub.on(EventType.OPERATOR_ASYNC, (execution) => {
311+
if (
312+
!execution.parentExecution ||
313+
!execution.parentExecution.isRunning
314+
) {
315+
proxyStateTree.getMutationTree().flush(true)
316+
}
312317
})
313318
eventHub.on(EventType.ACTION_END, (execution) => {
314319
if (!execution.parentExecution || !execution.parentExecution.isRunning)
@@ -331,15 +336,20 @@ export class Overmind<ThisConfig extends IConfiguration>
331336
})
332337
}
333338
eventHub.on(EventType.OPERATOR_ASYNC, (execution) => {
334-
const flushData = execution.flush(true)
335-
if (this.devtools && flushData.mutations.length) {
336-
this.devtools.send({
337-
type: 'flush',
338-
data: {
339-
...execution,
340-
...flushData,
341-
},
342-
})
339+
if (
340+
!execution.parentExecution ||
341+
!execution.parentExecution.isRunning
342+
) {
343+
const flushData = execution.flush(true)
344+
if (this.devtools && flushData.mutations.length) {
345+
this.devtools.send({
346+
type: 'flush',
347+
data: {
348+
...execution,
349+
...flushData,
350+
},
351+
})
352+
}
343353
}
344354
})
345355
eventHub.on(EventType.ACTION_END, (execution) => {

0 commit comments

Comments
 (0)