iOs9 XCODE error: JSON.stringify cannot serialize cyclic structures


#1

I updated my Xcode today and run my Ionic app on iOs9 build. New error pop up on Xcode console each time I click from a ng-repeat list to a detail view. Error is:

error JSON.stringify()ing argument: TypeError: JSON.stringify cannot serialize cyclic structures.

I do not know what is causing this error and it only output this error in Xcode when run the app on my iPhone 5s. I can feel there is a delay each time I click a list item within a ng-repeat list. So I am using AngularFire / Firebase to load the items from firebase and ng-repeat them on an Ionic list. Tag each item in a list go to a detail view. Error output when I tag the item.


#2

I am getting this error. Have you figured out how to fix this?


#3

I’m getting this error when running the app through Xcode, but not when using “ionic serve”. Any direction on how to fix it? The JSON payload I’m getting is pretty simple when this happens. There are no circular references in the JSON.

[EDIT]
Well, I just figured out what was causing it in my case. I noticed the line where it appeared to be choking on me:
<p><strong>Premiered:</strong> {{getFormattedDate(show.premiered) | date:'MMMM y'}}</p>

The function it’s running:
getFormattedDate(stringDate: string) { return new Date(stringDate) }
As soon as I commented that line out, it works fine. Not sure where it’s blowing up in there, but it’s gotta be some core thing doing it. There isn’t much going on here that I have control over. Ionic serve displays the date just fine.


#4

Follow up:

Though the previous post edit did fix one of these issues, I’m still getting the same error after I open a modal couple times, then try to close it. No clue what’s going on with this one. :frowning:

[EDIT]
After more digging, I found that the second error actually started from a “More tasks executed then were scheduled.” error that eventually led to the red herring error. If you comment out the following from your www/build/js/angular2-polyfils.js file, it fixed THIS issue for me. :slight_smile:
if (next < 0) { throw new Error('More tasks executed then were scheduled.'); }

I should also note that I’m dealing with Ionic2, and this post was tagged with Ionic, so hopefully I didn’t hijack it. :wink:


#5

Hi, i have same problem with this to format date in ionic 2 framework. will you please tell me how can i fixed this issue. in here i can see you told that you change angular2-polyfils.js file but in ionic 2 i do not have this file. do you have any idea how i can fix this. thank you


#6

I am also having a similar issue while using Sinch-RTC SDK “error JSON.stringify()ing argument: TypeError: JSON.stringify cannot serialize cyclic structures” this only occurs with ios 9 and at the same working fine for ios10.


#7

For those getting this error, it usually means you are console.loging a cyclic structure. Cordova’s console plugin is converting your object to JSON but it’s failing, and only in Safari. It’s not a fatal error.


#8

Thanks for the detail. I got it because I was using console.log(window);