ngrx / store-devtools

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

Store subscribe throws "TypeError: toISOString is not a function" when devtools enabled #61

Open naorrosenberg opened 7 years ago

naorrosenberg commented 7 years ago

Trying to use the devtools I get this Chrome console error:

onError: TypeError: toISOString is not a function
    at String.toJSON (<anonymous>)
    at Object.<anonymous> (http://localhost:3000/polyfills.dll.js:505:15)
    at derez (<anonymous>:2:5166)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5605)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5605)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5605)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5605)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5605)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5605)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5605)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5605)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5605)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at derez (<anonymous>:2:5787)
    at Object.decycle (<anonymous>:2:5824)
    at Object.e.stringify (<anonymous>:1:9180)
    at tryCatchStringify (<anonymous>:1:18835)
    at stringify (<anonymous>:1:18935)
    at toContentScript (<anonymous>:1:20155)
    at Function.sendMessage [as send] (<anonymous>:1:20641)
    at DevtoolsExtension.webpackJsonpac__name_.57.DevtoolsExtension.notify (http://localhost:3000/vendor.bundle.js:1462:32)
    at ScanSubscriber.accumulator (http://localhost:3000/vendor.bundle.js:1351:31)
    at ScanSubscriber._tryNext (http://localhost:3000/vendor.dll.js:94063:27)
    at ScanSubscriber._next (http://localhost:3000/vendor.dll.js:94056:25)
    at ScanSubscriber.Subscriber.next (http://localhost:3000/vendor.dll.js:457:18)
    at WithLatestFromSubscriber._next (http://localhost:3000/vendor.dll.js:96801:34)
    at WithLatestFromSubscriber.Subscriber.next (http://localhost:3000/vendor.dll.js:457:18)
    at Notification.observe (http://localhost:3000/vendor.dll.js:24076:50)
    at QueueAction.ObserveOnSubscriber.dispatch [as work] (http://localhost:3000/vendor.dll.js:47801:22)
    at QueueAction.AsyncAction._execute (http://localhost:3000/vendor.dll.js:24288:18)
    at QueueAction.execute (http://localhost:3000/vendor.dll.js:97134:18)
    at QueueScheduler.AsyncScheduler.flush (http://localhost:3000/vendor.dll.js:24361:32)
    at QueueAction.schedule (http://localhost:3000/vendor.dll.js:97128:24)
    at QueueScheduler.Scheduler.schedule (http://localhost:3000/vendor.dll.js:85633:53)
    at ObserveOnSubscriber.scheduleMessage (http://localhost:3000/vendor.dll.js:47808:56)
    at ObserveOnSubscriber._next (http://localhost:3000/vendor.dll.js:47811:14)
    at ObserveOnSubscriber.Subscriber.next (http://localhost:3000/vendor.dll.js:457:18)
    at MergeAllSubscriber.OuterSubscriber.notifyNext (http://localhost:3000/vendor.dll.js:642:26)
    at InnerSubscriber._next (http://localhost:3000/vendor.dll.js:85571:21)
    at InnerSubscriber.Subscriber.next (http://localhost:3000/vendor.dll.js:457:18)
    at MapSubscriber._next (http://localhost:3000/vendor.dll.js:12112:26)
    at MapSubscriber.Subscriber.next (http://localhost:3000/vendor.dll.js:457:18)
    at MergeAllSubscriber.OuterSubscriber.notifyNext (http://localhost:3000/vendor.dll.js:642:26)
    at InnerSubscriber._next (http://localhost:3000/vendor.dll.js:85571:21)
    at InnerSubscriber.Subscriber.next (http://localhost:3000/vendor.dll.js:457:18)
    at SkipSubscriber._next (http://localhost:3000/vendor.dll.js:94426:30)
    at SkipSubscriber.Subscriber.next (http://localhost:3000/vendor.dll.js:457:18)
    at Dispatcher.Subject.next (http://localhost:3000/vendor.dll.js:3420:25)
    at Dispatcher.BehaviorSubject.next (http://localhost:3000/vendor.dll.js:24033:31)
    at Store.webpackJsonpac__name_.61.Store.dispatch (http://localhost:3000/vendor.bundle.js:1682:26)
    at SafeSubscriber._next (http://localhost:3000/main.bundle.js:679:25)
    at SafeSubscriber.__tryOrUnsub (http://localhost:3000/vendor.dll.js:591:16)
    at SafeSubscriber.next (http://localhost:3000/vendor.dll.js:540:22)
    at Subscriber._next (http://localhost:3000/vendor.dll.js:493:26)
    at Subscriber.next (http://localhost:3000/vendor.dll.js:457:18)
    at MapSubscriber._next (http://localhost:3000/vendor.dll.js:12112:26)
    at MapSubscriber.Subscriber.next (http://localhost:3000/vendor.dll.js:457:18)
    at XMLHttpRequest.onLoad (http://localhost:3000/vendor.dll.js:61898:38)
    at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.dll.js:4304:31)
    at Object.onInvokeTask (http://localhost:3000/vendor.dll.js:30317:37)
    at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.dll.js:4303:36)
    at Zone.runTask (http://localhost:3000/polyfills.dll.js:4103:47)
    at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/polyfills.dll.js:4357:38)

Disabling the devtools from the app module makes this error disappear and the app behaves well. This happens only after the store holds some data.

package.json:

"dependencies": {
    "@ngrx/core": "^1.2.0",
    "@ngrx/store": "^2.2.2",
    "@ngrx/store-devtools": "^3.2.4",
}

app.module:

imports: [
    BrowserModule,
    HttpModule,
    StoreModule.provideStore(rootReducer),
    StoreDevtoolsModule.instrumentOnlyWithExtension({
      maxAge: 5
    }),
    RouterModule.forRoot(ROUTES, { useHash: true, preloadingStrategy: PreloadAllModules })
  ],

Suggestions?

theo-matzavinos commented 7 years ago

This happens when your actions contain values that are not serializable. For example I was getting the same error when dispatching an action with an ActivatedRouteSnapshot payload. My solution was to extract the necessary values into a plain object and use that as the payload.

naorrosenberg commented 7 years ago

Thanks @TheophileSketo. Is this a known bug/limitation or a feature by design?

Isn't extracting to a plain object contradicts using typed objects in typescript?