question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Max call stack exceeded (infinite loop) on mobile

See original GitHub issue
https://jsbin.com/nedubarado/edit?html

Steps to reproduce the problem

  1. Visit https://output.jsbin.com/nedubarado in Chrome
  2. Open DevTools and Enable device emulation image
  3. Select Galaxy S5 from the dropdown (any sufficiently small resolution screen should do) image
  4. Reload the page

What is the expected behaviour?

The page loads with the carousel

What is observed behaviour?

The page enters an infinite loop before reaching max call stack exceeded (and crashing outright on low-powered devices)

More Details

  • Which browsers/versions does it happen on? Tested on Chrome stable (66) and Canary (68)
  • Slick version? Tested and confirmed on 1.6 and 1.9
  • Did this work before? Unknown

@paulirish and I dug into this, it looks like the loop is in the init/refresh/checkResponsive loop https://github.com/kenwheeler/slick/blob/a2aa3fec335c50aceb58f6ef6d22df8e5f3238e1/slick/slick.js#L595-L608

The issue is that .init (which calls .setPosition) mutates the window.innerWidth which causes respondToWidth to change between checkResponsive calls. As a result, checkResponsive flips back and forth between activeBreakpoint = null and targetBreakpoint = null forever.

Originally reported in https://github.com/GoogleChrome/lighthouse/issues/5208

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

56reactions
willbroderickcommented, Sep 3, 2018

This seems to occur when the slideshow directly affects the page width - so when it’s the widest thing on the page. In our case, it was because we took overflow:hidden off the “slick-list” div. Using Slick’s styles unmodified, or making sure the slideshow is inside another container with overflow:hidden and width:100%, avoids this error (for us).

2reactions
hellojebuscommented, Oct 28, 2020

@willbroderick you are a god amongst mortals

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught RangeError: Maximum call stack size exceeded ...
So I know max call stack error is appearing when infinite loop is in occurring, by recursion. But I'm having this weird problem....
Read more >
JavaScript RangeError: Maximum Call Stack Size Exceeded
The RangeError: Maximum call stack size exceeded is thrown when a function call is made that exceeds the call stack size. This can...
Read more >
How to fix: "RangeError: Maximum call stack size exceeded"
A "RangeError: Maximum call stack size exceeded" is an error that occurs when a function or operation tries to execute too many nested...
Read more >
RangeError: Maximum call stack size exceeded - Codecademy
The error message is “maximum call stack size exceeded” because you accidentally created an infinite loop. Here is the infinite loop in your...
Read more >
InternalError: too much recursion - JavaScript - MDN Web Docs
The JavaScript exception "too much recursion" or "Maximum call stack size exceeded" occurs when there are too many function calls, or a function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found