React: The browser crashes when use React.lazy return Promise.resolve(undefined)

Created on 5 Mar 2019  路  5Comments  路  Source: facebook/react

Do you want to request a feature or report a bug?
bug

What is the current behavior?
The browser crashes

const Loading = () => <div>loading...</div>;
const Component = lazy(() => Promise.resolve(undefined));

function App() {
  return (
    <div className="App">
      <Suspense fallback={<Loading />}>
        <Component />
      </Suspense>
    </div>
  );
}

I can't provide an example of CodeSandbox, which would cause the browser to crash

What is the expected behavior?
throw Error

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
[email protected]
[email protected]
chrome 72.0.3626.119

Backlog Needs Investigation

Most helpful comment

Ok I see what you mean now. You鈥檙e saying React enters an infinite loop it lazy import resolves to undefined. That sounds like something we鈥檇 want to fix (even though it鈥檚 a bug in the application code).

All 5 comments

If the browser itself crashes then it's a browser bug. We can't fix it.

emm..., I mean the browser isn't responding, memory is up, and it feels like the program might be in an infinite loop

Ok I see what you mean now. You鈥檙e saying React enters an infinite loop it lazy import resolves to undefined. That sounds like something we鈥檇 want to fix (even though it鈥檚 a bug in the application code).

I have the same problem after using React.lazy for code splitting, sometimes there is memory soaring, the page is unresponsive, and the console is madly reporting an error. Has this problem been solved in the current release? @gaearon @raunofreiberg 聽(鈯櫵嶁姍)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.

Was this page helpful?
0 / 5 - 0 ratings