next.js
3b8cd922 - Fix error logging for `'use cache'` runtime errors in production (#86500)

Commit
29 days ago
Fix error logging for `'use cache'` runtime errors in production (#86500) In production, when throwing an error in `'use cache'` at runtime, we are currently logging the obfuscated error that React is producing when crossing the cache-server boundary. This is not ideal for investigating production issues so we're also logging the original error in the `'use cache'` wrapper as a work-around. But this error does not have a digest, which makes it non-obvious that it's the same error as the obfuscated one. With this PR we are fixing this by storing the original error (with a digest) in the `reactServerErrorsByDigest` map (moved to the work store), and retrieving it in the server environment when we log the error. Thus the obfuscated error is not logged, and the original error with a digest is logged instead. In development, we keep the existing behavior of logging the transported error, which also includes the dev-only `environmentName` property `'Cache'`. As part of this fix, we're consolidating the `createFlightReactServerErrorHandler` and `createHTMLReactServerErrorHandler` functions, which had a big overlap and confusing names, into a single `createReactServerErrorHandler` function. closes NAR-536
Author
Parents
Loading