rsnext/test/production
dpnolte 218d0709eb
feat: set status code to 500 if unexpected error occurs before streaming in app router (#56236)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

This PR therefore introduces to always set response status code to 500
unless it is a `NotFoundError` or `RedirectError`. This PR would fix
issue #56235. See also:
https://codesandbox.io/p/sandbox/nice-panini-2z3mcp .

**Current Behavior**
At the moment, when an unexpected error occurs during app server
rendering, a 200 ok is returned as status code. This seems to be
undesirable because of the success status CDNs will cache the error
pages and crawlers will index the page considering the error content as
the actual content.

**Desired Behavior**
This issue is related to discussion
https://github.com/vercel/next.js/discussions/53225. Even though I
understand that the response status code cannot be set if streaming has
started, in my view it would be best to set the response status to 500
whenever it can (so before the streaming has started) for SEO and (CDN)
http caching. This would also be consistent with how 404s currently
work; that is, response status code is set to 404 if `NotFoundError`
occurred before streaming (related
[issue](https://github.com/vercel/next.js/issues/43831) &
[PR](https://github.com/vercel/next.js/pull/55542)).

Ideally, when a runtime error happens after streaming, a `<meta
name="robots" content="noindex" />` would also be added. But I didn't
want to make the PR too complex before receiving feedback.

---------

Co-authored-by: Vũ Văn Dũng <me@joulev.dev>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2023-10-17 15:32:20 +02:00
..
app-dir feat: set status code to 500 if unexpected error occurs before streaming in app router (#56236) 2023-10-17 15:32:20 +02:00
app-dir-edge-runtime-with-wasm chore: remove experimental appDir: true from tests (#52291) 2023-07-05 19:17:29 -07:00
app-dir-hide-suppressed-error-during-next-export Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
app-dir-prefetch-non-iso-url Remove experimental config from create-next-app (#49241) 2023-05-05 00:22:28 -07:00
bfcache-routing fix bfcache restoration behavior (#54198) 2023-08-18 00:05:26 +02:00
build-spinners Use consistent name for App Router tests (#56352) 2023-10-06 11:06:06 +02:00
ci-missing-typescript-deps Add types as a default dependency into tests (#44140) 2022-12-19 19:05:53 +01:00
custom-error-500 Fix handling with custom _error and pages/500 (#40110) 2022-08-30 18:14:12 -05:00
custom-server server: bundle vendored react (#55362) 2023-09-15 19:49:39 +00:00
dependencies-can-use-env-vars-in-middlewares Remove static analysis of process.env (#50260) 2023-05-24 08:19:02 -07:00
deployment-id-handling Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
disable-fallback-polyfills Update flakey polyfills and acceptance tests (#45313) 2023-01-26 10:25:47 -08:00
edge-config-validations Rename allowDynamic to unstable_allowDynamic (#40496) 2022-09-12 15:32:18 -07:00
edge-runtime-is-addressable Upgrade edge-runtime + make EdgeRuntime value overridable with an env var on compilation (#38331) 2022-07-12 15:18:59 +00:00
edge-safe-dynamic-code Skip build-time dynamic code checks for specific polyfills in the Edge runtime (#52009) 2023-07-04 14:18:02 +00:00
emit-decorator-metadata Ensure next.url is used instead of next.appPort (#44163) 2022-12-19 13:29:50 -08:00
enoent-during-require Ensure ENOENT error is not ignored when loading pages (#37486) 2022-06-06 14:35:26 -04:00
escheck-output Update swc_core to v0.75.23 (#48098) 2023-04-18 08:59:52 +02:00
eslint-plugin-deps Upgrade typescript to 4.8.2 (#39979) 2022-08-29 16:56:02 +00:00
export Refactor next export tests (#45227) 2023-02-02 16:22:54 +00:00
exported-runtimes-value-validation feat: enhance warning messages about unanalyzable config field (#38907) 2022-07-22 19:31:47 +00:00
fallback-export-error Update check for fallback pages during export (#33323) 2022-01-17 14:44:45 +00:00
fatal-render-errror Ensure default _app is used when falling back to default _error (#39467) 2022-08-10 11:36:22 -05:00
generate-middleware-source-maps feat: enables 'edge' as a possible runtime for API routes (#44045) 2022-12-15 10:08:03 +01:00
handle-already-sent-response Redesign nextjs logging (#54713) 2023-09-05 11:40:00 +00:00
ipc-forbidden-headers add "expect" to list of forbidden IPC headers (#53947) 2023-08-12 19:38:38 +00:00
jest Allow jest to run with use server directive (#56148) 2023-09-28 14:15:51 +00:00
middleware-typescript Update default moduleResolution in tsconfig.json from node to bundler (#51957) 2023-07-18 15:11:09 +00:00
next-font Add next/font import (#45891) 2023-02-16 15:33:39 +01:00
pages-dir/production Decrease default test timeouts (#56116) 2023-09-27 23:55:20 +00:00
pnpm-support test(integration): fix --turbo tests fixture setup (#55293) 2023-09-18 17:46:07 +00:00
postcss-plugin-config-as-string allow to provide postcss plugin options as a string (#35173) 2022-04-08 16:58:50 +00:00
prerender-prefetch Tweak flakey prefetch test handling (#53391) 2023-07-31 16:20:43 +00:00
reading-request-body-in-middleware fix(stream): Allows body larger than 16 KiB with middleware (#41270) 2022-10-17 15:26:16 -07:00
standalone-mode Ensure tests suites have unique names (#56085) 2023-09-27 13:55:45 +02:00
supports-module-resolution-nodenext Fix failing TS test from new release (#54523) 2023-08-24 11:36:38 -07:00
typescript-basic Fix next/dynamic types for resolving named export module (#43923) 2022-12-10 17:35:13 +00:00