Skip to content

Commit d415aa7

Browse files
fix(overmind): ensure bound execution is actually an execution
1 parent f5ac417 commit d415aa7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
getFunctionName,
4646
getActionPaths,
4747
createActionsProxy,
48+
EXECUTION,
4849
} from './utils'
4950
import {
5051
operatorStarted,
@@ -389,6 +390,7 @@ export class Overmind<ThisConfig extends IConfiguration>
389390
private createExecution(name, action, parentExecution) {
390391
if (IS_PRODUCTION) {
391392
return ({
393+
[EXECUTION]: true,
392394
parentExecution,
393395
getMutationTree: () => {
394396
return this.proxyStateTree.getMutationTree()
@@ -399,6 +401,7 @@ export class Overmind<ThisConfig extends IConfiguration>
399401

400402
const mutationTrees: any[] = []
401403
const execution = {
404+
[EXECUTION]: true,
402405
actionId: this.actionReferences.indexOf(action),
403406
executionId: this.nextExecutionId++,
404407
actionName: name,
@@ -474,6 +477,11 @@ export class Overmind<ThisConfig extends IConfiguration>
474477
private createAction(name, action) {
475478
this.actionReferences.push(action)
476479
const actionFunc = (value?, boundExecution?: Execution) => {
480+
// Developer might unintentionally pass more arguments, so have to ensure
481+
// that it is an actual execution
482+
boundExecution =
483+
boundExecution && boundExecution[EXECUTION] ? boundExecution : undefined
484+
477485
if (IS_PRODUCTION || action[IS_OPERATOR]) {
478486
const execution = this.createExecution(name, action, boundExecution)
479487
this.eventHub.emit(EventType.ACTION_START, {

packages/node_modules/overmind/src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const IS_DEVELOPMENT =
88
!process.env.NODE_ENV || process.env.NODE_ENV === 'development'
99
export const IS_OPERATOR = Symbol('operator')
1010
export const ORIGINAL_ACTIONS = Symbol('origina_actions')
11+
export const EXECUTION = Symbol('execution')
1112

1213
export class MockedEventEmitter {
1314
emit() {}

0 commit comments

Comments
 (0)