ngrx / store-devtools

Developer Tools for @ngrx/store
MIT License
325 stars 38 forks source link

TypeError: Cannot read property 'type' of undefined #60

Closed richarddavenport closed 7 years ago

richarddavenport commented 7 years ago

Not sure why this is happening. I don't have any effects that do not dispatch actions. When performAction gets called:

 performAction: function (action) {
        if (typeof action.type === 'undefined') {
            throw new Error('Actions may not have an undefined "type" property. ' +
                'Have you misspelled a constant?');
        }
        return { type: ActionTypes.PERFORM_ACTION, action: action, timestamp: Date.now() };
    },

I'm not getting the thrown error because action is undefined.

``` ERROR TypeError: Cannot read property 'type' of undefined at Object.performAction (actions.js:17) at MapSubscriber.liftAction [as project] (utils.js:20) at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:77) at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at MergeAllSubscriber.webpackJsonpac__name_../node_modules/rxjs/OuterSubscriber.js.OuterSubscriber.notifyNext (OuterSubscriber.js:19) at InnerSubscriber.webpackJsonpac__name_../node_modules/rxjs/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:23) at InnerSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at SkipSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/skip.js.SkipSubscriber._next (skip.js:46) at SkipSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at Dispatcher.webpackJsonpac__name_../node_modules/rxjs/Subject.js.Subject.next (Subject.js:55) at Dispatcher.webpackJsonpac__name_../node_modules/rxjs/BehaviorSubject.js.BehaviorSubject.next (BehaviorSubject.js:44) at Store.webpackJsonpac__name_../node_modules/@ngrx/store/src/store.js.Store.next (store.js:35) at SafeSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:236) at SafeSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.SafeSubscriber.next (Subscriber.js:185) at Subscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber._next (Subscriber.js:125) at Subscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at MergeAllSubscriber.webpackJsonpac__name_../node_modules/rxjs/OuterSubscriber.js.OuterSubscriber.notifyNext (OuterSubscriber.js:19) at InnerSubscriber.webpackJsonpac__name_../node_modules/rxjs/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:23) at InnerSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:83) at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/switchMap.js.SwitchMapSubscriber.notifyNext (switchMap.js:124) at InnerSubscriber.webpackJsonpac__name_../node_modules/rxjs/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:23) at InnerSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:83) at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at FinallySubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber._next (Subscriber.js:125) at FinallySubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at CatchSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber._next (Subscriber.js:125) at CatchSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/switchMap.js.SwitchMapSubscriber.notifyNext (switchMap.js:124) at InnerSubscriber.webpackJsonpac__name_../node_modules/rxjs/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:23) at InnerSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) at XMLHttpRequest.onLoad (http.es5.js:1205) at ZoneDelegate.ac_polyfills../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:398) at Object.onInvokeTask (core.es5.js:4116) at ZoneDelegate.ac_polyfills../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:397) at Zone.ac_polyfills../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:165) at XMLHttpRequest.ZoneTask.invoke (zone.js:460) at ____________________Elapsed_4483_ms__At__Tue_May_02_2017_10_01_55_GMT_0500__CDT_ () at getStacktraceWithUncaughtError (long-stack-trace-zone.js:39) [angular] at new LongStackTrace (long-stack-trace-zone.js:33) [angular] at Object.onScheduleTask (long-stack-trace-zone.js:109) [angular] at Object.onScheduleTask (zone.js:274) [angular] at zoneAwareAddListener (zone.js:1453) [angular] at XMLHttpRequest.addEventListener (eval at createNamedFn (zone.js:1587), :3:43) [angular] at Observable._subscribe (http.es5.js:1252) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable._trySubscribe (Observable.js:57) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:45) [angular] at Object.subscribeToResult (subscribeToResult.js:22) [angular] at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/switchMap.js.SwitchMapSubscriber._innerSub (switchMap.js:101) [angular] at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/switchMap.js.SwitchMapSubscriber._next (switchMap.js:94) [angular] at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:83) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:83) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:83) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:83) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:83) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at XMLHttpRequest.onLoad (http.es5.js:1205) [angular] at Object.onInvokeTask (core.es5.js:4116) [angular] at XMLHttpRequest.ZoneTask.invoke (zone.js:460) [] at ____________________Elapsed_98_ms__At__Tue_May_02_2017_10_01_55_GMT_0500__CDT_ () at getStacktraceWithUncaughtError (long-stack-trace-zone.js:39) [angular] at new LongStackTrace (long-stack-trace-zone.js:33) [angular] at Object.onScheduleTask (long-stack-trace-zone.js:109) [angular] at Object.onScheduleTask (zone.js:274) [angular] at zoneAwareAddListener (zone.js:1453) [angular] at XMLHttpRequest.addEventListener (eval at createNamedFn (zone.js:1587), :3:43) [angular] at Observable._subscribe (http.es5.js:1252) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable._trySubscribe (Observable.js:57) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:45) [angular] at MapOperator.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapOperator.call (map.js:54) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at MapOperator.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapOperator.call (map.js:54) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at MapOperator.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapOperator.call (map.js:54) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at MapOperator.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapOperator.call (map.js:54) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at MapOperator.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapOperator.call (map.js:54) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at SwitchMapOperator.webpackJsonpac__name_../node_modules/rxjs/operator/switchMap.js.SwitchMapOperator.call (switchMap.js:67) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at CatchOperator.webpackJsonpac__name_../node_modules/rxjs/operator/catch.js.CatchOperator.call (catch.js:79) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at FinallyOperator.webpackJsonpac__name_../node_modules/rxjs/operator/finally.js.FinallyOperator.call (finally.js:26) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at MapOperator.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapOperator.call (map.js:54) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at Object.subscribeToResult (subscribeToResult.js:22) [angular] at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/switchMap.js.SwitchMapSubscriber._innerSub (switchMap.js:101) [angular] at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/switchMap.js.SwitchMapSubscriber._next (switchMap.js:94) [angular] at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/switchMap.js.SwitchMapSubscriber.notifyNext (switchMap.js:124) [angular] at InnerSubscriber.webpackJsonpac__name_../node_modules/rxjs/InnerSubscriber.js.InnerSubscriber._next (InnerSubscriber.js:23) [angular] at InnerSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at FirstSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/first.js.FirstSubscriber._emitFinal (first.js:135) [angular] at FirstSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/first.js.FirstSubscriber._emit (first.js:118) [angular] at FirstSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/first.js.FirstSubscriber._next (first.js:97) [angular] at FirstSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at DistinctUntilChangedSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/distinctUntilChanged.js.DistinctUntilChangedSubscriber._next (distinctUntilChanged.js:103) [angular] at DistinctUntilChangedSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:83) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapSubscriber._next (map.js:83) [angular] at MapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at ReplaySubject.webpackJsonpac__name_../node_modules/rxjs/ReplaySubject.js.ReplaySubject._subscribe (ReplaySubject.js:55) [angular] at ReplaySubject.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable._trySubscribe (Observable.js:57) [angular] at ReplaySubject.webpackJsonpac__name_../node_modules/rxjs/Subject.js.Subject._trySubscribe (Subject.js:97) [angular] at ReplaySubject.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:45) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable._subscribe (Observable.js:116) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable._trySubscribe (Observable.js:57) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:45) [angular] at MapOperator.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapOperator.call (map.js:54) [angular] at Observable.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at Store.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable._subscribe (Observable.js:116) [angular] at Store.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable._trySubscribe (Observable.js:57) [angular] at Store.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:45) [angular] at MapOperator.webpackJsonpac__name_../node_modules/rxjs/operator/map.js.MapOperator.call (map.js:54) [angular] at Store.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at DistinctUntilChangedOperator.webpackJsonpac__name_../node_modules/rxjs/operator/distinctUntilChanged.js.DistinctUntilChangedOperator.call (distinctUntilChanged.js:60) [angular] at Store.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at FirstOperator.webpackJsonpac__name_../node_modules/rxjs/operator/first.js.FirstOperator.call (first.js:70) [angular] at Store.webpackJsonpac__name_../node_modules/rxjs/Observable.js.Observable.subscribe (Observable.js:42) [angular] at Object.subscribeToResult (subscribeToResult.js:22) [angular] at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/switchMap.js.SwitchMapSubscriber._innerSub (switchMap.js:101) [angular] at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/switchMap.js.SwitchMapSubscriber._next (switchMap.js:94) [angular] at SwitchMapSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at FilterSubscriber.webpackJsonpac__name_../node_modules/rxjs/operator/filter.js.FilterSubscriber._next (filter.js:88) [angular] at FilterSubscriber.webpackJsonpac__name_../node_modules/rxjs/Subscriber.js.Subscriber.next (Subscriber.js:89) [angular] at Dispatcher.webpackJsonpac__name_../node_modules/rxjs/Subject.js.Subject.next (Subject.js:55) [angular] at Dispatcher.webpackJsonpac__name_../node_modules/rxjs/BehaviorSubject.js.BehaviorSubject.next (BehaviorSubject.js:44) [angular] at Store.webpackJsonpac__name_../node_modules/@ngrx/store/src/store.js.Store.dispatch (store.js:32) [angular] at EmployeeListComponent.webpackJsonpac__name_../src/app/employees/components/employee-list/employee-list.component.ts.EmployeeListComponent.search (employee-list.component.ts:52) [angular] at EmployeeListComponent.webpackJsonpac__name_../src/app/employees/components/employee-list/employee-list.component.ts.EmployeeListComponent.ngOnInit (employee-list.component.ts:47) [angular] at checkAndUpdateDirectiveInline (core.es5.js:10705) [angular] at checkAndUpdateNodeInline (core.es5.js:12084) [angular] at checkAndUpdateNode (core.es5.js:12052) [angular] at debugCheckAndUpdateNode (core.es5.js:12681) [angular] at debugCheckDirectivesFn (core.es5.js:12622) [angular] at Object.eval [as updateDirectives] (EmployeeListComponent_Host.html:1) [angular] at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:12607) [angular] at checkAndUpdateView (core.es5.js:12019) [angular] at callWithDebugContext (core.es5.js:13007) [angular] at Object.debugCheckAndUpdateView [as checkAndUpdateView] (core.es5.js:12547) [angular] at ViewRef_.webpackJsonpac__name_../node_modules/@angular/core/@angular/core.es5.js.ViewRef_.detectChanges (core.es5.js:10116) [angular] at :3000/sbMain.bundle.js:20487:102 [angular] at m.$digest (angular.js:17515) [angular] at m.$apply (angular.js:17790) [angular] at cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js:20:488 [angular] at Object.invoke (angular.js:4718) [angular] at c (angular.js:1759) [angular] at Object.Bc [as bootstrap] (angular.js:1779) [angular] at bootstrap (static.es5.js:51) [angular] at :3000/sbMain.bundle.js:21407:39 [angular] at Object.onInvoke (core.es5.js:4125) [angular] at NgZone.webpackJsonpac__name_../node_modules/@angular/core/@angular/core.es5.js.NgZone.run (core.es5.js:3994) [] at UpgradeModule.webpackJsonpac__name_../node_modules/@angular/upgrade/@angular/upgrade/static.es5.js.UpgradeModule.bootstrap (static.es5.js:1170) [] at :3000/sbMain.bundle.js:65940:17 [] at :3000/polyfills.bundle.js:16426:57 [] at drainMicroTaskQueue (zone.js:591) [] at HTMLDocument.ZoneTask.invoke (zone.js:464) [] ```
fiznool commented 7 years ago

I'm seeing what looks like the same issue in an Ionic 3 project, with the following versions:

├─ @ngrx/core@1.2.0
├─ @ngrx/effects@2.0.3
├─ @ngrx/store-devtools@3.2.4
├─ @ngrx/store@2.2.2

Stack trace:

core.es5.js:1084 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'type' of undefined
TypeError: Cannot read property 'type' of undefined
    at Object.performAction (actions.js:17)
    at MapSubscriber.liftAction [as project] (utils.js:20)
    at MapSubscriber._next (map.js:77)
    at MapSubscriber.Subscriber.next (Subscriber.js:89)
    at MergeAllSubscriber.OuterSubscriber.notifyNext (OuterSubscriber.js:19)
    at InnerSubscriber._next (InnerSubscriber.js:23)
    at InnerSubscriber.Subscriber.next (Subscriber.js:89)
    at SkipSubscriber._next (skip.js:46)
    at SkipSubscriber.Subscriber.next (Subscriber.js:89)
    at Dispatcher.Subject.next (Subject.js:55)
    at Object.performAction (actions.js:17)
    at MapSubscriber.liftAction [as project] (utils.js:20)
    at MapSubscriber._next (map.js:77)
    at MapSubscriber.Subscriber.next (Subscriber.js:89)
    at MergeAllSubscriber.OuterSubscriber.notifyNext (OuterSubscriber.js:19)
    at InnerSubscriber._next (InnerSubscriber.js:23)
    at InnerSubscriber.Subscriber.next (Subscriber.js:89)
    at SkipSubscriber._next (skip.js:46)
    at SkipSubscriber.Subscriber.next (Subscriber.js:89)
    at Dispatcher.Subject.next (Subject.js:55)
    at c (polyfills.js:3)
    at Object.reject (polyfills.js:3)
    at NavControllerBase._fireError (nav-controller-base.js:322)
    at NavControllerBase._failed (nav-controller-base.js:310)
    at nav-controller-base.js:365
    at t.invoke (polyfills.js:3)
    at Object.onInvoke (core.es5.js:4125)
    at t.invoke (polyfills.js:3)
    at r.run (polyfills.js:3)
    at polyfills.js:3
fiznool commented 7 years ago

Never mind. I was being an idiot. I was using the store to dispatch an action inside one of my effects, instead of just returning the action.

I was doing:

@Effect() userTier$ = this.actions$
  .ofType(Actions.REACHED_THRESHOLD)
  .map(toPayload)
  .mergeMap(reachedThreshold => {
    return Observable.of(this.store.dispatch(
      reachedThreshold ?
        this.actions.setAsTier2User() :
        this.actions.setAsTier1User()
      ));
  });

When I should have been doing:

@Effect() userTier$ = this.actions$
  .ofType(Actions.REACHED_THRESHOLD)
  .map(toPayload)
  .mergeMap(reachedThreshold => {
    return Observable.of(reachedThreshold ?
      this.actions.setAsTier2User() :
      this.actions.setAsTier1User()
    );
  });
richarddavenport commented 7 years ago

Forgot I reported this. That's what I was doing to. I too was an idiot 😀

sundarcodes commented 7 years ago

I should join in the idiot gang as well :)