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

subscribeAction no longer fails when error is thrown #1620

Brimstedt opened this issue Sep 26, 2019 · 1 comment


Copy link

@Brimstedt Brimstedt commented Sep 26, 2019



Reproduction link

Steps to reproduce

Since version 3.1.0 there is a 'fix' which I consider a regression. "Errors thrown inside action subscribers no longer cause the entire action to fail."

  1. Create an action subscriber

  2. throw an error in the subscriber

  3. --> action is performed regardless of exception

What is expected?

When an error is thrown in an action subscriber, I expect the action to be interrupted and the exception to bubble up to the caller.

What is actually happening?

The exception is quietly swallowed.
Also seems i cannot catch the exception.

Im not sure you can revert to the old behaviour since other users might be dependent on this silent swallowing (though I fail to see why anyone would like such behaviour :-) ... fail early and never ignore exceptions.)
If it cant be reverted, it would be nice to be able to interrupt the action flow by some other mechanism.

I use this as part of validation/permission framework to prevent user in UI to perform actions shes not allowed to do. Of course this is checked in backend also, but user feedback can be given quicker and easier this way and it does not require implementation in every action - only in the subscriber.


This comment has been minimized.

Copy link

@ktsn ktsn commented Nov 9, 2019

I don't think interrupting an action from its subscriber is a good idea. Generally speaking, in observer pattern, a subject (action in Vuex) just send messages and forget about it, and subscriber don't push back the message to subject.

Back and forthing messages between action and subscriber would complicate and make the code hard to understand.

In your use case, you can make enhancer function to explicitly apply the validation logic to your actions.

function validator(fn) {
  return (ctx, payload) => {
    // validate payload

    return fn(ctx, payload)

export default {
  actions: {
    myAction: validator((ctx, payload) => {
      // ...
@ktsn ktsn closed this Nov 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.