Max call stack exceeded (infinite loop) on mobile
See original GitHub issuehttps://jsbin.com/nedubarado/edit?html
Steps to reproduce the problem
- Visit https://output.jsbin.com/nedubarado in Chrome
- Open DevTools and Enable device emulation
- Select Galaxy S5 from the dropdown (any sufficiently small resolution screen should do)
- 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:
- Created 5 years ago
- Reactions:1
- Comments:12
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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).
@willbroderick you are a god amongst mortals