-
Notifications
You must be signed in to change notification settings - Fork 27.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error digest from Server Action is not logged server-side #60684
Comments
Can confirm, same issue here, no error digest in the log's. |
### 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
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/competent-firefly-9ncwrh?file=%2Fapp%2Fpage.tsx%3A18%2C7
To Reproduce
Current vs. Expected behavior
Client side receives a digest, but this is not logged anywhere (that I can find) on the server.
This means that you can't search the logs for this digest to find out what caused it.
Verify canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023 Binaries: Node: 20.9.0 npm: 9.8.1 Yarn: 1.22.19 pnpm: 8.10.2 Relevant Packages: next: 14.0.4 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router
Which stage(s) are affected? (Select all that apply)
Vercel (Deployed), Other (Deployed)
Additional context
When a server action throws an error, in production this is hashed into a digest that is sent to the client. This is a security mechanism that lets developers track errors, without potentially leaking sensitive information like stack-traces to end-users.
This digest is only accessible in the browser.
It would be incredibly helpful if this digest was logged on the server as well. This means the browser could track the error (to say Sentry), and then this can be tied to a server-tracked error too.
Note the documentation explicitly states:
However, as the digest is not logged on the server, it is not possible to match the corresponding error.
Based on a quick look through the code, I've found this function
createErrorHandler
might be a reasonable place to incorporate this change.next.js/packages/next/src/server/app-render/create-error-handler.tsx
Line 91 in ab7b0f5
I have put together a minimal change that I believe could help here:
https://github.com/Winwardo/next.js/pull/1/files
There is a related issue on React GitHub, where other people would like to pass error codes from the server to client: facebook/react#27362 "[Feature Request]: RSC error - allow error.code or an other specialized prop to be forwarded to the client #27362"
Thanks 👍
The text was updated successfully, but these errors were encountered: