Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting maximum call stack exceeded on backend.js when rendering many elements. #16501

Closed
ryan-rushton opened this issue Aug 20, 2019 · 14 comments

Comments

@ryan-rushton
Copy link

Details

Using version 4.0.2 (8/15/2019) I am getting a maximum call stack size exceeded when my app starts up. While my app using this is a little different I have replicated the issue using a fresh create-react-app. I will include the App.js code below.

Steps to reproduce

  1. Create a new app using version 3.0.1 of create-react-app
  2. Replace the code in App.js with the code listed below
  3. Inspect the console, there should be a stack trace from a maximum call stack exceeded error

App.js

import React from 'react';
import logo from './logo.svg';
import './App.css';

const createDivs = num => {
    const rtn = [];
    for(let i = 0; i < num; i++) {
        const key = `div-${i}`;
        rtn.push(<div className={key} key={key} />)
    }
    return rtn;
}

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
        <a
          className="App-link"
          href="https://reactjs.org"
          target="_blank"
          rel="noopener noreferrer"
        >
          Learn React
        </a>
      </header>
      <div>
        {createDivs(15000)}
      </div>
    </div>
  );
}

export default App;

Call Stack

backend.js:formatted:2097 Uncaught RangeError: Maximum call stack size exceeded
    at ge (backend.js:formatted:2097)
    at Ge (backend.js:formatted:2435)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
    at Ge (backend.js:formatted:2478)
ge @ backend.js:formatted:2097
Ge @ backend.js:formatted:2435
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
Ge @ backend.js:formatted:2478
postMessage (async)
r @ contentScript.js:1
88 @ contentScript.js:1
n @ contentScript.js:1
(anonymous) @ contentScript.js:1
(anonymous) @ contentScript.js:1
Show 170 more frames

This was not an issue in the previous version of react-devtools.

@omar-aguilar
Copy link

Is kind of annoying having the backend.js loaded in your page and getting executed on top of all your code all the time.

  // the prototype stuff is in case document.createElement has been modified
  (function () {
    var script = document.constructor.prototype.createElement.call(document, 'script');
    script.src = "chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/backend.js";
    script.charset = "utf-8";
    document.documentElement.appendChild(script);
    script.parentNode.removeChild(script);
  })()

@gaearon
Copy link
Collaborator

gaearon commented Aug 20, 2019

Thanks for the report. This looks like a bug and we’ll investigate it shortly.

Is kind of annoying having the backend.js loaded in your page and getting executed on top of all your code all the time.

This is how DevTools always worked, we don’t really have other options.

I’m sorry it broke now, but it’s been a big rewrite, and things will take another week or two to fully stabilize. Sorry for the trouble.

@ryan-rushton
Copy link
Author

Thanks @gaearon and @bvaughn, if it’s something you’d like a hand with I’d be happy to make a contribution. Just let me know if that’s the case.

@bvaughn
Copy link
Contributor

bvaughn commented Aug 24, 2019

I think this PR fixes the extreme deep and wide tree cases:
bvaughn/react-devtools-experimental#385

As a note, 15k divs is still not recommended 😄

@MVMS1994
Copy link

MVMS1994 commented Apr 12, 2020

Is there any updates on this thread? I'm facing the exact problem. And in my case, it's 20K table rows.
I know it's a bad practice to have so many elements and pagination is recommended. But as a platform, I'd like to fix this before introducing pagination to my code.

Edit: I would like to lend a hand to close this issue. :)

@ryan-rushton
Copy link
Author

@MVMS1994 it was fixed at one point but I haven't opened up the app I built which has a lot of divs in a while. Maybe this is a regression?

@bvaughn
Copy link
Contributor

bvaughn commented Apr 13, 2020

Is there any updates on this thread?

If there were an update, it would be on the the issue.

I did a little investigation into this (via #16627) but it turned out to be pretty complicated to get right in all of the methods, and it hasn't been a priority yet.

@markbmullins
Copy link

markbmullins commented May 17, 2020

Just wanted to report the same issue using version 4.6.0.

 1 of 1 unhandled error

Unhandled Runtime Error
RangeError: Maximum call stack size exceeded

Call Stack
ye
chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/react_devtools_backend.js (6:16636)
He
chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/react_devtools_backend.js (6:21203)
He
chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/react_devtools_backend.js (6:21869)
He
chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/react_devtools_backend.js (6:21869)
He
chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/react_devtools_backend.js (6:21803)
He
chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/react_devtools_backend.js (6:21803)
He
chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/react_devtools_backend.js (6:21869)
He
...

@bladerunner2020
Copy link

bladerunner2020 commented Jan 8, 2021

Encountered this issue while using an SVG image with many paths (in my case the 4631 paths are rendered ok, but when I add one more I got the dev tools error).

react_devtools_backend.js:5158 Uncaught RangeError: Maximum call stack size exceeded
    at shouldFilterFiber (react_devtools_backend.js:5158)
    at mountFiberRecursively (react_devtools_backend.js:5820)
    at mountFiberRecursively (react_devtools_backend.js:5880)
    at mountFiberRecursively (react_devtools_backend.js:5880)
    at mountFiberRecursively (react_devtools_backend.js:5880)

I import the svg using: import { ReactComponent as Map } from './map.svg';

@asumaran
Copy link

I think the same issue is happening to me:

react_devtools_backend.js:5158 Uncaught RangeError: Maximum call stack size exceeded
    at shouldFilterFiber (react_devtools_backend.js:5158)
    at mountFiberRecursively (react_devtools_backend.js:5820)
    at mountFiberRecursively (react_devtools_backend.js:5871)
    at mountFiberRecursively (react_devtools_backend.js:5871)
    at mountFiberRecursively (react_devtools_backend.js:5880)
    at mountFiberRecursively (react_devtools_backend.js:5880)
    at mountFiberRecursively (react_devtools_backend.js:5880)
    at mountFiberRecursively (react_devtools_backend.js:5880)
    at mountFiberRecursively (react_devtools_backend.js:5880)
    at mountFiberRecursively (react_devtools_backend.js:5880)

I'm rendering (among other things) about 10k very small react elements

function PlaceholderRow() {
  return (
    <tr className="candidate-row">
      <td colSpan="10"></td>
    </tr>
  );
}

React Developer Tools 4.10.1 (12/4/2020)

@FSM1
Copy link

FSM1 commented Mar 15, 2021

Also getting this error rendering 2 complex SVG's on the page. Any advice in resolving would be appreciated.

@gaearon
Copy link
Collaborator

gaearon commented Mar 15, 2021

To be clear, the error is coming from React DevTools. While it's unfortunate and would be nice to fix, you can always disable the extension if it's interfering with your work.

@FSM1
Copy link

FSM1 commented Mar 16, 2021

@gaearon absolutely understood. Got around this by rendering the SVG as an <img src={SVG}/> instead of a React component

@jasekiw
Copy link

jasekiw commented Apr 15, 2024

To be clear, the error is coming from React DevTools. While it's unfortunate and would be nice to fix, you can always disable the extension if it's interfering with your work.

Hi @gaearon, I was able to reproduce this error when rendering a large datalist - 5000 options. I disabled the extension and am still seeing this error. It seems the error is happening during a hot reload but the exception is coming from react-dom_client.js. So it appears at least now this issue is no longer contained to just the dev tools.

I created a reproduceable demo below. let me know if it is reproduceable for you.

https://github.com/jasekiw/scheduleFibersWithFamiliesRecursivelyBug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants