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

The third parameter of dispatch is undefined. #1618

yywc opened this issue Sep 20, 2019 · 1 comment · Fixed by #1640


Copy link

@yywc yywc commented Sep 20, 2019



Reproduction link

Steps to reproduce

  1. go to link;
  2. open Console of page in the bottom;
  3. see the undefined;

What is expected?

In theory,it should show the code of cb.

What is actually happening?

In fact,it's undefined.

According to Vuex code, wrappedActionHandler function provide two params.One is payload,the other is cb.

  // notice the cb
  entry.push(function wrappedActionHandler (payload, cb) {
    let res =, {
      dispatch: local.dispatch,
      commit: local.commit,
      getters: local.getters,
      state: local.state,
      rootGetters: store.getters,
      rootState: store.state
    }, payload, cb) // pass it and do nothing
    if (!isPromise(res)) {
      res = Promise.resolve(res)
    if (store._devtoolHook) {
      return res.catch(err => {
        store._devtoolHook.emit('vuex:error', err)
        throw err
    } else {
      return res

  // dispatch function only use payload
  dispatch (_type, _payload) {
    // check object-style dispatch
    const {
    } = unifyObjectStyle(_type, _payload)

    const action = { type, payload }
    const entry = this._actions[type]
    // ...
    const result = entry.length > 1
      ? Promise.all( => handler(payload))) // only payload parameter
      : entry[0](payload)

So I think cb parameter is useless and it should be delete from code in order to
eliminate misunderstanding.


This comment has been minimized.

Copy link

@gitlab-winnie gitlab-winnie commented Oct 30, 2019

This may be a duplicate of #1571.

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.