vuejs / devtools-v6

⚙️ Browser devtools extension for debugging Vue.js applications.
https://devtools-v6.vuejs.org/
MIT License
24.66k stars 4.15k forks source link

Snapshots being just JSON lose any class information #492

Open GufNZ opened 6 years ago

GufNZ commented 6 years ago

I am storing classes in my state, to simplify the code, but this causes 2 issues with the dev tools:

The console logger that can print mutations manages to do this correctly, tho it doesn't do time travel.

posva commented 6 years ago

FYI it's better to save only serializable data in your state as this will allow you to save them with some external service in production mode. Meaning that you will be able to completely mimic any fail situation that a user encountered and allowing you to reproduce user errors without them having to submit a bug report at all. To support this also outside of vue-devtools, we would need to export the custom serialization so users can post that instead of the plain JSON.stringify (I'm not sure how services like Sentry serialize Classes)

baikunz commented 6 years ago

I faced this issue for quite some time now, without knowing what was going on. I finally discovered today the source of my troubles :(

I usually store only POJO's on my store, however I had to deal with firestore on a recent project. Things started going wild when I stored objects with dates properties coming from firestore. They are returning all date fields in a class instance.

Everything is working just fine except when I open the devtools !

How would one tackle this issue ? I mean, since there is no explicit schema on a firestore database, a date could be stored on any field, I can't just run through every field and convert it if it's a date.

Got any idea ?

Akryum commented 6 years ago

Dates are already serialized and restored.

baikunz commented 6 years ago

Indeed they are, but that's for the javascript ones. Not the ones returned by Firestore. They are using a wrapper class around dates. And obviously those are not serialized correctly.