ical.js icon indicating copy to clipboard operation
ical.js copied to clipboard

JSON.stringify can cause "too much recursion" involving ICAL.Time.fromData

Open PaulMorris opened this issue 5 years ago • 0 comments

See bugzilla bug 1546606 starting with comment 23. In short, an assertion in a unit test calls JSON.stringify on its arguments to log the result of the assertion, and that causes a "too much recursion" error that involves ICAL.Time.fromData. It looks like this when you add a console.trace at the top of that fromData function:

 0:19.93 pid:3758 JavaScript error: resource://calendar/modules/ical.js, line 4946: too much recursion
 0:19.93 pid:3758 console.trace: 
 0:19.93 pid:3758 resource://calendar/modules/ical.js 4946 fromData
 0:19.93 pid:3758 resource://calendar/modules/ical.js 4813 icaltime
 0:19.94 pid:3758 resource://calendar/modules/ical.js 4863 clone
 0:19.94 pid:3758 resource://calendar/modules/ical.js 5040 startOfWeek
 0:19.94 pid:3758 resource://calendar/calendar-js/calDateTime.js 165 get startOfWeek
 0:19.94 pid:3758 resource://testing-common/Assert.jsm 87 getMessage
 0:19.94 pid:3758 resource://testing-common/Assert.jsm 127 Assert.AssertionError
 0:19.94 pid:3758 resource://testing-common/Assert.jsm 220 proto.report
 0:19.94 pid:3758 resource://testing-common/Assert.jsm 354 strictEqual
 0:19.94 pid:3758 [...]/obj-artifact/_tests/xpcshell/comm/calendar/test/unit/test_caldav_requests.js 903 test_freebusy_request

Without the console.trace the error is:

0:02.87 pid:3993 JavaScript error: resource://calendar/modules/ical.js, line 5720: too much recursion
 0:03.51 pid:3993 JavaScript error: resource://calendar/modules/ical.js, line 5720: too much recursion

The 5720 line reference points to setupNormalizeAttributes > defineAttr > defineProperty > set > setTimeAttr

PaulMorris avatar Dec 05 '19 16:12 PaulMorris