mobxjs / mobx-angular

The MobX connector for Angular.
MIT License
483 stars 59 forks source link

Option to disable the MobxAngularDebug utility in production builds #23

Closed returnlytom closed 7 years ago

returnlytom commented 7 years ago

MobxAngularDebug is very helpful during the development process. But per Can I Use, approximately ~5% of users are running browsers that do not support Web Storage. Subsequently, every so often I receive a notification via Sentry that my production app crashed during an instantiation of an observable (which was ultimately triggered by the lack of localStorage support).

Thus, it would be great if there was a build time flag we could use to disable including this utility with the production bundle.

adamkleingit commented 7 years ago

Hi @returnlytom , That's weird because before accessing localStorage I check if it exists using this line of code:

if (typeof localStorage === 'undefined' || typeof console === 'undefined') {
  return;
}  

Can you send me the crash report?

returnlytom commented 7 years ago

Two examples, with the OS / browser info:

image

null is not an object (evaluating 'localStorage["mobx-angular-debug"]')

image

Cannot read property 'mobx-angular-debug' of null
adamkleingit commented 7 years ago

Thanks. So localStorage is null. I will add that check as well in 1.8.0 - should solve it.

adamkleingit commented 7 years ago

Deployed - can you verify?

returnlytom commented 7 years ago

Thanks for the fix; will push to production and keep you posted.

returnlytom commented 7 years ago

Appears to be working, but now crashing here: image

Seems to be limited to this OS / browser profile: image

adamkleingit commented 7 years ago

Pushed to 1.8.1 - can you check? By the way - does it work in development? What are you doing differently in production build?

returnlytom commented 7 years ago

Will do.

Not doing anything different in development; but we don't test on all browsers