mixpanel-js icon indicating copy to clipboard operation
mixpanel-js copied to clipboard

Maximum callstack exceeded

Open sara-jegorova opened this issue 3 years ago • 3 comments

There seems to be a problem with the truncate function in https://github.com/mixpanel/mixpanel-js/blob/master/dist/mixpanel.cjs.js#L421, where it gets stuck on an infinite loop. I found the issue via our runtime error logs, and it seems to happen only to samsung internet 16.0 browser. I was not able to reproduce the issue myself, but it might be worth looking into. Here's a screenshot of the callstack: Screenshot 2022-02-10 at 13 53 24

I'm using npm package mixpanel-browser version 2.41.0.

sara-jegorova avatar Feb 10 '22 11:02 sara-jegorova

Thanks for the report @sara-jegorova. Do you know whether you're passing any property values to track() that aren't simply serializable, for instance a native Error object as in https://github.com/mixpanel/mixpanel-js/issues/317? This infinite recursion issue happens when you pass an Object to track() that has a circular reference to itself somewhere, and you mention it only happens on one browser, hence the suspicion that you're tracking something as a prop that the browser has natively produced.

tdumitrescu avatar Feb 10 '22 20:02 tdumitrescu

Hi @tdumitrescu , thanks for having a look. The only complex info I'm passing to track() is from reportWebVitals() in CRA which uses the web-vitals library, as it passes Metric: https://github.com/GoogleChrome/web-vitals/blob/main/src/types.ts#L39 . I think that if I just stop passing entries, these errors should go away.

sara-jegorova avatar Feb 11 '22 11:02 sara-jegorova

Yes, generally you want to choose explicitly how to serialize values like that. This will also ensure that your tracking properties remain consistent across browsers.

tdumitrescu avatar Feb 11 '22 17:02 tdumitrescu