Uncaught RangeError: Maximum call stack size exceeded when adding task to gannt chart
This error is almost always means you have a problem with recursion in JavaScript code, as there isn't any other way in JavaScript to consume lots of stack. Sometimes calling a recursive function over and over again, causes the browser to send you Maximum call stack size exceeded error message as the memory that can be allocated for your use is not unlimited.
How to fix
Wrap your recursive function call into a -
- setTimeout
- setImmediate or
- process.nextTick
Also, you can localize the issue by setting a breakpoint on RangeError type of exception , and then adjust the code appropriately. Moreover, you can managed to find the point that was causing the error by check the error details in the Chrome dev toolbar console , this will give you the functions in the call stack, and guide you towards the recursion that's causing the error.
|
async Task Add()
{
var taskData = new TaskData()
{
TaskId = TaskCollection.Count + 1,
TaskName = "Added:" + (Convert.ToInt32(TaskCollection.Count) + 1),
StartDate = new DateTime(2019, 04, 02),
EndDate = new DateTime(2019, 04, 08),
Duration = "5days"
};
await Gantt.AddRecordAsync(taskData, 2);
}
|
- 4 Replies
- 3 Participants
-
JR Joe Robe
- Jun 17, 2021 08:55 PM UTC
- Nov 3, 2021 06:56 AM UTC