Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition with undo/redo #5

Open
nlochschmidt opened this issue Jul 16, 2018 · 2 comments
Open

Race condition with undo/redo #5

nlochschmidt opened this issue Jul 16, 2018 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@nlochschmidt
Copy link

nlochschmidt commented Jul 16, 2018

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?

@andrewbeng89 andrewbeng89 added the enhancement New feature or request label Feb 8, 2019
@mlnmln
Copy link
Member

mlnmln commented May 6, 2019

hi @nlochschmidt

sorry for not getting back earlier, we recently moved the repository and missed a couple of notifications.

@andrewbeng89
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants