Unverified Commit 54a963b6 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Update displayed error message for rsc case (#52004)

We show the "Application error: a client-side exception has occurred (see the browser console for more information)" error incorrectly when a server-side error occurs (a digest is present) when we should be showing an error saying it is in fact a server side error and should check the logs there. This change will make the error message more accurate for users to look up

Fixes NEXT-1263
parent d02f60b9
...@@ -100,6 +100,7 @@ export class ErrorBoundaryHandler extends React.Component< ...@@ -100,6 +100,7 @@ export class ErrorBoundaryHandler extends React.Component<
} }
export default function GlobalError({ error }: { error: any }) { export default function GlobalError({ error }: { error: any }) {
const digest: string | undefined = error?.digest
return ( return (
<html> <html>
<head></head> <head></head>
...@@ -107,12 +108,13 @@ export default function GlobalError({ error }: { error: any }) { ...@@ -107,12 +108,13 @@ export default function GlobalError({ error }: { error: any }) {
<div style={styles.error}> <div style={styles.error}>
<div> <div>
<h2 style={styles.text}> <h2 style={styles.text}>
Application error: a client-side exception has occurred (see the {`Application error: a ${
browser console for more information). digest ? 'server' : 'client'
}-side exception has occurred (see the ${
digest ? 'server logs' : 'browser console'
} for more information).`}
</h2> </h2>
{error?.digest && ( {digest ? <p style={styles.text}>{`Digest: ${digest}`}</p> : null}
<p style={styles.text}>{`Digest: ${error.digest}`}</p>
)}
</div> </div>
</div> </div>
</body> </body>
......
...@@ -1546,7 +1546,7 @@ createNextDescribe( ...@@ -1546,7 +1546,7 @@ createNextDescribe(
expect( expect(
await browser.waitForElementByCss('body').elementByCss('h2').text() await browser.waitForElementByCss('body').elementByCss('h2').text()
).toBe( ).toBe(
'Application error: a client-side exception has occurred (see the browser console for more information).' 'Application error: a server-side exception has occurred (see the server logs for more information).'
) )
expect( expect(
await browser.waitForElementByCss('body').elementByCss('p').text() await browser.waitForElementByCss('body').elementByCss('p').text()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment