react / react/react

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

Open
#15,019 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Resolution: Backlog Type: Needs Investigation
Dominant language
JavaScript
Stars
251k
Forks
51.4k
Avg merge
2d 4h
Merged PRs (30d)
53

Description

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?
react@16.8.3
react-dom@16.8.3
chrome 72.0.3626.119

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the React.lazy example with React 16.8.3 and inspect the lazy-loading entry point involved when the loader resolves to undefined. The fix is complete when this invalid result throws an Error instead of crashing the browser, with a regression test covering the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.