optimizely / nuclear-js

Reactive Flux built with ImmutableJS data structures. Framework agnostic.
https://optimizely.github.io/nuclear-js/
MIT License
2.23k stars 142 forks source link

Logging fails on older Android browsers when called with `null` or `undefined` #216

Closed raulmatei closed 7 years ago

raulmatei commented 8 years ago

Hi,

I was debugging a web app on an older Android device with the default browser, version 4.3 and found out that when I was dispatching without payload something fails. I started debugging deeper and I realized that the issue is in the logging module when calling console.debug with an undefined payload. The error is TypeError: Cannot call method 'toString' of undefined and is triggered by: https://github.com/optimizely/nuclear-js/blob/master/src/logging.js#L18

Can we guard against this? I mean we can log something like 'No payload' or skip the logging if the payload is undefined/null.

Of course I can always send an empty object as a payload but I prefer dispatch(ACTION_TYPE), because is shorter.

Thanks, Raul.

jordangarcia commented 8 years ago

Hey Raul,

I've been travelling lately and haven't gotten a chance to address this. Should be a simple fix. I will do soon.

jordangarcia commented 7 years ago

@raulmatei This should be fixed in 1.4.0 by the ability to pass in your own logger

raulmatei commented 7 years ago

@jordangarcia - I've seen the change log, but haven't had time to test. I think it should be fine to close this, as one could simply pass in a custom logger that handles the case presented in this issue.