Files
Jiachi LiuandGitHub 92e4a4b78c Associate server error digest with browser logged one (#61592)
### What

#### Core
This PR respect the error's digest when recieves new error occurred from
server side, and it will be logged into client on production with the
same `digest` property.
If we discover the original RSC error in SSR error handler, retrieve the
original error

#### Tests

* Move the errors related tests from `test/e2e/app-dir/app` to a
separate test suite `test/e2e/app-dir/errors`
* Add a new test case for logging the original RSC error
* Add a new test case for logging the original Server Action error


### Why

This will help associate the `digest` property of the errors logged from
client with the actual generated server errors. Previously they're
different as we might re-compute the digest proper in handler that react
server renderer thinks it's a new error, which causes we have 2
different errors logged on server side, and 1 logged on client side. The
one on client side can associate to the server errors but it's from
react renderer which is not the original error.

Closes NEXT-2094
Fixes #60684
2024-02-06 13:39:12 +01:00

30 lines
526 B
JavaScript

'use client'
import { useState } from 'react'
import { serverAction } from './action'
export default function Home() {
const [response, setResponse] = useState(null)
return (
<div>
<button
id="button"
onClick={async function () {
try {
await serverAction()
} catch (e) {
console.log(e)
setResponse(e)
}
}}
>
Crash
</button>
<br />
<p id="digest">{response?.digest}</p>
</div>
)
}