Next.js Discord

Discord Forum

Does this error message shows in production

Unanswered
Alligator mississippiensis posted this in #help-forum
Open in Discord
Avatar
Alligator mississippiensisOP
I'm using a library that causes this error:
"Cannot read properties of undefined"

On dev there is a react popup that shows the error,
will this popup appear on production for users,
or the error will just be written in the dev tools?

5 Replies

Avatar
joulev
in prod it will be console.error'd if it was a recoverable client error, or a generic error page if it was not recoverable
Avatar
Alligator mississippiensisOP
Sorry for my misunderstanding, but what recoverable means?
Avatar
joulev
recoverable means the page can still be rendered, i.e. your react component still returns something to be displayed normally. usually this means you throw an error in an event handler or useEffect รขโ‚ฌโ€œ it affects the event handling but not the component itself

irrecoverable means you throw during the component rendering so react cannot render the component anymore, example:
function Component() {
  const [isErrored, setIsErrored] = useState(false);
  if (isErrored) throw new Error();
  return <button onClick={() => setIsErrored(true)}>Click me</button>;
}
"Cannot read properties of undefined" can be thrown during server/client component rendering (irrecoverable) or during event handlers/useEffect (recoverable)
Avatar
Alligator mississippiensisOP
I see, i'll try to look more into this topic, thank you!