react: Bug: (17.0.0-rc.0) No changes to Native Component Stacks in production environment

The React 17 RC blog post states “In React 17, the component stacks are generated using a different mechanism that stitches them together from the regular native JavaScript stacks. This lets you get the fully symbolicated React component stack traces in a production environment.”

I’ve been trying to see a difference between React 16.13.1 and React 17.0.0.rc.0, and so far have been unable to do so.

React version: 17.0.0.rc.0

Steps To Reproduce

  1. Start a new app with Create React App.
  2. Run npm install react-error-boundary.
  3. Use the code shown below in your App.js.
  4. Run npm run build to create a production build.
  5. Start a web server and open in a browser to see the error.
import React from 'react';
import { ErrorBoundary } from "react-error-boundary";

function ErrorFallback({ error }) {
  return (
    <div>
      <p>Something went wrong:</p>
      <pre style={{ color: "red" }}>{error.message}</pre>
    </div>
  )
}

function Bomb(foo) {
  return (
    <>
      <h1>💣</h1>
      {foo.toUpperCase()}
    </>
  )
}

function App() {
  return (
    <ErrorBoundary FallbackComponent={ErrorFallback} onReset={() => {}}>
      <h1>Error Testing</h1>
      <Bomb />
    </ErrorBoundary>
  );
}

export default App;

The current behavior

The stack trace I’m getting is exactly the same with React 16.13.1 and React 17.0.0-rc.0.

error-trace

The expected behavior

I’m expecting to get component names in my stack trace, or to see some difference in the stack traces between React versions.

Apologies if I’m debugging the wrong thing here, but I’m trying to figure out what actually changed in React 17. Appreciate your time.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17

Most upvoted comments

Are there any browsers that rewrite the link? We should definitely bring this up as a feature request.

Same error built with react-scripts@3.4.3

Chrome 84

React 17 stacks in Chrome 84

Firefox 79

React 17 stacks in firefox 79

  • both apply source maps to the code links in the JS stacks
  • both don’t apply source maps to the code links in the component stack
  • only chrome linkifies the code frame in the component stack

As far as I can tell this is a devtools specific feature and they are very picky with the format where they apply source maps to the frames. If you simply log error.stack (e.g. console.log(error.stack) or even console.log(event.stack.slice(0, 500))) you’ll end up with source-mapped links. But as soon as you prefix the logged stack chrome devtools won’t apply source maps (e.g console.log(my message: ${error.stack})

PS: Having the error appear twice in the console is quite confusing but I believe this was always the case.

Really appreciate all of your fast help here!

I see the difference between React 16 and 17 during development now with the help of your screenshots. In my production environment I am now seeing the following:

--- App.js:5:10
s@http://localhost:8000/static/js/main.15f3e38c.chunk.js:1:470
a@http://localhost:8000/static/js/2.477a9a31.chunk.js:2:1611
u App.js:6:10
---

So I think we’re probably good here. Give me a bit of time to process your comments, and see if I can decode these to what I’m looking for.