Skip to content

Uncaught (in promise) Error: idle status delay must be a number type for idleStatus === 'AWAY' #15

@oliverbienert

Description

@oliverbienert

Hi,
I setup redux-idle-monitor as described in the readme. When running it, the above error appears in the console.
With developer tools I digged into this:

var delay = dispatch(idleStatusDelay(idleStatus));

However, the returned type is a Promise, not a number. What's wrong here? My action looks:

export const idleStatusDelay = idleStatus => (dispatch, getState) => {
  const exp_delta = getExpirationDelta();
  if(idleStatus === IDLESTATUS_AWAY)
    return 20000;
  if(idleStatus === IDLESTATUS_INACTIVE)
    return exp_delta;
  if(idleStatus === IDLESTATUS_EXPIRED)
    return exp_delta + 1000; // Log them out after another minute after they enter the inactive status
};

Also store configuration is as you described:

import { middleware as idleMiddleware, actions as idleActions } from "../components/redux-idle-monitor"


export default function configureStore(initialState) {
  const middewares = [
    // Add other middleware on this line...
    apiMiddleware,
    // Redux middleware that spits an error on you when you try to mutate your state either inside a dispatch or between dispatches.
    reduxImmutableStateInvariant(),

    // thunk middleware can also accept an extra argument to be passed to each thunk action
    // https://github.com/gaearon/redux-thunk#injecting-a-custom-argument
    thunkMiddleware,
    idleMiddleware
  ];

  const store = createStore(rootReducer, initialState, compose(
    applyMiddleware(...middewares),
    window.devToolsExtension ? window.devToolsExtension() : f => f // add support for Redux dev tools
    )
  );

  let currentIsAuthorized = null;

  store.subscribe(() => {
    let previousIsAuthorized = currentIsAuthorized;
    let state = store.getState();
    currentIsAuthorized = state.auth.get("isAuthenticated");
    if(currentIsAuthorized !== previousIsAuthorized)
      store.dispatch((currentIsAuthorized ? idleActions.start : idleActions.stop)())
  });

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions