AzureAD / azure-activedirectory-library-for-js

The code for ADAL.js and ADAL Angular has been moved to the MSAL.js repo. Please open any issues or PRs at the link below.
https://github.com/AzureAD/microsoft-authentication-library-for-js/tree/dev/maintenance/adal-angular
Apache License 2.0
627 stars 374 forks source link

JSON.stringify in stateChangeHandler throws on circular reference #806

Closed ReeseJones closed 5 years ago

ReeseJones commented 6 years ago

in adal-angular.js on line 318 there is the following line:

_adal.verbose("State change error occured. Error: " + typeof (error) === 'string' ? error : JSON.stringify(error));

The stateChangeErrorHandler sometimes receives error objects containing circular references which causes the stringify to throw, and obfuscate the errors that are actually happening.

It ends up looking kind of like this. image

In our case we had a transition from one state to another while there was an ongoing transition already which produces an error correctly, however it wasn't obvious because because this state change error handler couldnt stringify the error was and throwing in of itself.

rohitnarula7176 commented 5 years ago

@ReeseJones Thank you for pointing out this issue. I have submitted a PR for this issue. Can you please confirm if it resolves your issue. We will add this fix to our next release in a couple of weeks.

nehaagrawal commented 5 years ago

@ReeseJones Can you please let us know what is the error string that is being passed to JSON.stringify(error) that ended up causing circular reference error?

nehaagrawal commented 5 years ago

We have merged the PR. I will update this issue with the version details when we release. Closing this issue for now.