Skip to content

Race condition with undo/redoΒ #5

@nlochschmidt

Description

@nlochschmidt

Steps to reproduce: Use the test case from my branch https://github.com/nlochschmidt/undo-redo-vuex/blob/test-action-groups/test/test-action-group-undo.js and replace https://github.com/nlochschmidt/undo-redo-vuex/blob/b6786ea2298ab2eb2ef3e2ad20b34a7f62478009/test/test-action-group-undo.js#L74-L85 with

test.serial('Undo secondGroup and mutation without group', async t => {
  await undo();
  await undo();
  t.deepEqual(Vue.plain(store.state.list), firstGroupItems);
});

Expected result: Both undo operations happening one after the other and the assertion matches

Actual result: The undo operations are intertwined (can be reproduced fairly consistently with node v10.6). As a result, some of the replayed mutations are actually registered as new mutations.

The most likely reason is the way the undo and redo operations are triggered which is done using the subscribeAction method on the Vuex store. However the time at which subscribeAction is called is not clearly defined (vuejs/vuex#1098) and the subscribe methods can not deal with asynchronous callbacks.

I am not sure how to fix this at the moment. But maybe you have an idea?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions