Commit graph

16531 commits

Author SHA1 Message Date
Jiachi Liu
89bccd05de
Refactor metadata og and twitter title to be always presented (#52320)
Follow up for #52196 

The og title should be always resolved as `AbsoluteTemplate`. Move all the title resolving inside the og metadata resolving, so that it's aligned with type. And we don't have to check title everywhere, when og/twitter metadata is resolved, `title` is always presented as a property with `AbsoluteTemplate` type

Closes NEXT-1399
2023-07-07 11:07:52 +00:00
Tobias Koppers
a3d5a855eb
add incremental cache for node.js app rendering (#52172)
### What?

adds `incrementalCache` to app rendering to add support for
`unstable_cache`
2023-07-07 11:33:51 +02:00
Lee Robinson
deb1d19ee5
docs: Clarify create-next-app requires public GitHub URLs. (#52367)
x-ref: https://twitter.com/gwenshap/status/1677111697537130497
2023-07-07 08:30:26 +00:00
Zack Tanner
412992ad6e
fix: prevent infinite dev refresh on nested parallel routes (#52362)
### What?
HMR causes infinite reloads for parallel routes when the corresponding page component is nested

### Why?
In 4900fa21b078fd1ec1adc5d570fcfb560be8aeb6, code was added to remove `/@children` from the page path (if present) but in 59b36349eb86427ac7b679ac62fa6628c9fc4886, `normalizeParallelKey` removes the @ prefix from children, so this doesn't seem to be catching the scenario it was intended to prevent

### How?
This updates the existing replace logic to consider `/children/page` rather than `/@children/page` -- it doesn't seem like `/@children` is a valid scenario given the `normalizeParallelKey` behavior

Fixes #52342 and addresses the concerns in https://github.com/vercel/next.js/pull/52061#issuecomment-1619145129
2023-07-07 07:41:21 +00:00
Yagiz Nizipli
eb3d748759
perf: simplify getShortDynamicParamType on app-render (#52355)
Removes the unnecessary switch case statement and provide a fast path for `optional-catchall` edge case.
2023-07-07 00:35:55 +00:00
Steven
27217146cf
fix: metadatabase warning message (#52363)
This PR is a small grammar change to the warning message since "fallbacks to" is not grammatically correct.
2023-07-07 00:08:10 +00:00
Gabriel França
2c12c6add9
chore(docs): fix link to useSearchParams (#52348)
### Overview
The purpose of this PR is to remove the wrong link to useParams in the useSearchParams documentation.

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-07-06 23:33:55 +00:00
Yagiz Nizipli
4b2eef4600
perf: use fs.opendir for better resource usage (#52341)
This pull request replaces `fs.readdir` with `fs.opendir` for better memory usage. `fs.readdir` consumes the path and only returns value when the iteration is finished, but `fs.opendir` both returns `fs.Dirent` which is better, since we are calling an additional `fs.stat` for each iteration, but also streams the output, so that we don't store the whole array of inputs in the memory.
2023-07-06 23:11:09 +00:00
Alex Kirszenberg
1c2de8330c
Make get_client_chunking_context independent of context (#51928)
The client chunking context must remain the same for a given Next.js compilation. For production builds, we only need to create it once for both the Pages Router and the App Router. As such, it doesn't make sense for it to accept a context type, at least not as an enum. A vector of enums or flags could also work. Considering the only case where the chunking context differes today is the web entry source, we might as well make the web entry source also serve under `_next` (or remove it entirely?).
2023-07-06 22:06:31 +00:00
Yagiz Nizipli
1fbb5138c8
perf: use fs.readdirSync with withFileTypes (#52340)
There is no need to make a `fs.statSync` call for each file while reading a directory, since `fs.readdirSync` supports `withFileTypes` property that returns a `fs.Dirent` which includes the necessary information for detecting if the particular item is directory or not.
2023-07-06 21:39:22 +00:00
JJ Kasper
f0fc83b40c
Fix trailing slash with locale domain (#52343)
This ensures we normalize the trailing slash with a locale domain href
correctly.

Reproduction with patch can be seen here
https://reproduction-link-inconsistency-96cg0lqc9-vtest314-ijjk-testing.vercel.app/dynamic/alpha/

Fixes: https://github.com/vercel/next.js/issues/47661
2023-07-06 13:56:30 -07:00
vercel-release-bot
1045644655 v13.4.9 2023-07-06 20:50:37 +00:00
vercel-release-bot
21392cb4e0 v13.4.9-canary.3 2023-07-06 17:07:58 +00:00
doinki
c878caa3bc
Fix to use keep-alive in standalone mode (#50221)
You can specify keepAliveTimeout as an environment variable in
standalone mode, but there is a problem with it not being properly
applied.

#46052 

#### before
<img width="574" alt="2023-05-24 12 49 12"
src="https://github.com/vercel/next.js/assets/90969158/9014252e-dcac-4b32-805a-68e844e853b1">
<img width="574" alt="2023-05-24 12 49 20"
src="https://github.com/vercel/next.js/assets/90969158/8c5672b2-8af8-4751-aa0c-7347428c3cbb">

#### after

<img width="574" alt="2023-05-24 1 19 12"
src="https://github.com/vercel/next.js/assets/90969158/96a83b0d-1dd1-45b7-b053-e0103185dd47">
2023-07-06 09:59:59 -07:00
Yiğithan
ce483fd7c3
fix(create-next-app): add missing metadata type (#52299)
This pull request adds the missing `Metadata` type declaration to the
root layout of the `create-next-app` templates. The metadata object was
missing its type definition, which has been resolved by adding the
appropriate type import and annotation.

---------
2023-07-06 09:58:43 -07:00
Hong Zheng You
a17f07aa5b
doc: update typo in instrumentation page (#52311)
There's a small typo: `[pagesExtension]` -> `[pageExtensions]`. 

Got confused why my instrumentation hook was not called. When I searched my source code for `pagesExtension` there was no occurrence so I thought I did not use it; soon after I realized the field in the docs has a typo .
2023-07-06 16:45:39 +00:00
Sebastian Markbåge
b095e9e980
Test Progressive Enhancement of Server Actions (#52062)
Adds a regression test for testing progressive enhancement of Server
Actions. Both when passed from a Server Component and when imported into
a Client Component.

#51723 landed a bit too early which broke this but it'll be fixed again
once React is upgraded.

Co-authored-by: Shu Ding <g@shud.in>
2023-07-06 18:21:59 +02:00
Steven
914158607f
chore: fix next dev turbopack benchmark (#52328)
This is a follow up to PR https://github.com/vercel/next.js/pull/52291
which removed the `next.config.js` which started causing an error during
CI:

```
@next/swc:test-cargo-bench: error: couldn't read packages/next-swc/crates/next-dev/benches/next.config.js: No such file or directory (os error 2)
@next/swc:test-cargo-bench:   --> packages/next-swc/crates/next-dev/benches/bundler.rs:74:13
@next/swc:test-cargo-bench:    |
@next/swc:test-cargo-bench: 74 |             include_bytes!("next.config.js"),
@next/swc:test-cargo-bench:    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@next/swc:test-cargo-bench:    |
@next/swc:test-cargo-bench:    = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)
@next/swc:test-cargo-bench: 
@next/swc:test-cargo-bench: error: could not compile `next-dev` (bench "mod") due to previous error
@next/swc:test-cargo-bench: warning: build failed, waiting for other jobs to finish...
@next/swc:test-cargo-bench:  ELIFECYCLE  Command failed with exit code 101.
```

https://github.com/vercel/next.js/actions/runs/5476339074/jobs/9973767389#step:27:959
2023-07-06 08:58:25 -07:00
Tyler Lutz
38e45f25b2
Add app router example (#52066)
- Add app router example to 03-environment-variables.mdx

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-07-06 15:53:54 +00:00
Muhammad Rio Ananta Firdaus
202dcb0e32
Update 10-router-handlers.mdx (#52098)
Fixes a link for the Dynamic Functions shortcut.
2023-07-06 15:27:59 +00:00
Delba de Oliveira
931b1b5d87
[Docs] Add manual installation instructions for pages (#51995)
Fixes: https://github.com/vercel/next.js/issues/51938
2023-07-06 15:06:31 +00:00
Alex Kirszenberg
ec19537127
Named page chunks (#51921)
Depends on https://github.com/vercel/turbo/pull/5398 (and downstack) on
the Turbo side.

This PR makes it so the output path of Node.js entry chunks for pages is
determined solely from the pathname. This isn't actually necessary for
pages, but it makes for easier debugging anyway. See the Turbo PR for
more details.

This also changes the page structure so it also works if there is no
`pages` directory. In this case, we still want to use pages' default
_app, _document, and _error pages, even with existing app routes. So an
empty page structure should still have an effect.

## Turbopack updates

* https://github.com/vercel/turbo/pull/5415 <!-- Will Binns-Smith -
Turbopack: Execution tests in node.js -->
* https://github.com/vercel/turbo/pull/5461 <!-- Tobias Koppers - use a
lock to ensure atomic invalidation from file changes -->
* https://github.com/vercel/turbo/pull/5398 <!-- Alex Kirszenberg -
Configure the path of the Node.js entry chunk -->
* https://github.com/vercel/turbo/pull/5469 <!-- Tobias Koppers - allow
hmr tests to correctly detect hmr event -->
2023-07-06 16:31:22 +02:00
Jimmy Lai
2743d0c037
msic: disable otel esm test (#52325)
x-ref:
https://github.com/vercel/next.js/actions/runs/5475379084/jobs/9971770362?pr=52320

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-07-06 15:56:53 +02:00
Delba de Oliveira
26c0730911
[Docs] Document redirect parameters (#51987)
Fixes: 

- https://github.com/vercel/next.js/issues/51975
- [Linear](https://linear.app/vercel/issue/DX-1713/docs-redirect-is-missing-an-explanation-not-redirecttype)
2023-07-06 13:10:10 +00:00
Andrew Clark
bb8cf5e3f2
Update eslint-plugin-react-hooks to 5.0.0-canary-7118f5dd7-20230705 (#52275)
*This is a resubmit of https://github.com/vercel/next.js/pull/52268
because I neglected to run `pnpm install` last time and it was
accidentally automerged before I could fix it.*

5.0.0-canary-7118f5dd7-20230705 includes a new lint error for hook calls
inside an async component, a common mistake when refactoring Server
Components to Client Components, or vice versa.

This updates the dependency in eslint-config-next.

<!-- 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 #

-->

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-07-06 14:23:14 +02:00
Steven
6dafc4229d
chore(deps): bump react to 7118f5dd7 (#52282)
Fixes #49409

### React upstream changes

- https://github.com/facebook/react/pull/27045
- https://github.com/facebook/react/pull/27051
- https://github.com/facebook/react/pull/27032
- https://github.com/facebook/react/pull/27031
- https://github.com/facebook/react/pull/27029
- https://github.com/facebook/react/pull/27028
- https://github.com/facebook/react/pull/27027
- https://github.com/facebook/react/pull/27019
- https://github.com/facebook/react/pull/26954
- https://github.com/facebook/react/pull/26987
- https://github.com/facebook/react/pull/26985
- https://github.com/facebook/react/pull/26933
- https://github.com/facebook/react/pull/26625
- https://github.com/facebook/react/pull/27011
- https://github.com/facebook/react/pull/27008
- https://github.com/facebook/react/pull/26997
- https://github.com/facebook/react/pull/26989
- https://github.com/facebook/react/pull/26955
- https://github.com/facebook/react/pull/26963
- https://github.com/facebook/react/pull/26983
- https://github.com/facebook/react/pull/26914
- https://github.com/facebook/react/pull/26951
- https://github.com/facebook/react/pull/26977
- https://github.com/facebook/react/pull/26958
- https://github.com/facebook/react/pull/26940
- https://github.com/facebook/react/pull/26939
- https://github.com/facebook/react/pull/26887
- https://github.com/facebook/react/pull/26947
- https://github.com/facebook/react/pull/26945
- https://github.com/facebook/react/pull/26942
- https://github.com/facebook/react/pull/26938
- https://github.com/facebook/react/pull/26844
- https://github.com/facebook/react/pull/25510
- https://github.com/facebook/react/pull/26932
- https://github.com/facebook/react/pull/26896
- https://github.com/facebook/react/pull/26913
- https://github.com/facebook/react/pull/26888
- https://github.com/facebook/react/pull/26827
- https://github.com/facebook/react/pull/26889
- https://github.com/facebook/react/pull/26877
- https://github.com/facebook/react/pull/26873
- https://github.com/facebook/react/pull/26880
- https://github.com/facebook/react/pull/26842
- https://github.com/facebook/react/pull/26858
- https://github.com/facebook/react/pull/26754
- https://github.com/facebook/react/pull/26753
- https://github.com/facebook/react/pull/26881

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-07-06 14:04:21 +02:00
Shu Ding
37c40b79c5
Update checksum algorithm to SHA1 (#52102)
Update some of the hash we're using in the framework to use `sha1` instead. It's usually up to 20% faster than `sha256` and slightly faster than `md5`. All these places are only using the algorithm to generate a checksum, so there's no security concern to switch the algorithm.

- packages/next/src/build/index.ts: using the hash as the key to track the traced files
- packages/next/src/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts: CSS modules class name generation
- packages/next/src/build/webpack/loaders/next-flight-css-loader.ts: checksum for server imported CSS's file content
- packages/next/src/build/webpack/loaders/next-font-loader/index.ts: font asset hash
- packages/next/src/cli/next-dev.ts: instrumentation file hash
- packages/next/src/server/dev/hot-reloader.ts: module hash for HMR
2023-07-06 08:50:51 +00:00
bottxiang
cee0599628
fix wrong Link import (#52298)
<!-- 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?
This component cause Error: Element type is invalid: expected a string
(for built-in components) or a class/function (for composite components)
but got:
undefined](https://stackoverflow.com/questions/69211200/next-js-error-element-type-is-invalid-expected-a-string-for-built-in-componen)
### Why?
Wrong Link import, default export should be import as `import Link from
"next/link"` instead of `import {Link} from "next/link"`;
`;
`
### How?
import Link from "next/link"

Closes NEXT-
Fixes #

-->
2023-07-05 22:08:22 -07:00
Nourman Hajar
ea676960de
fix: correct modularizeImports for antd & ant-design/icons (#52169)
<!-- 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 #

-->

### What? / Why?

A follow up of previous fix #52148.

This PR fixes the error `SyntaxError: Cannot use import statement
outside a module` when developing with antd on next canary. I suspect
this happens because ant doesn't have a `type: "module"` in their
`package.json` files, but the previous `modularizeImports` config uses
the `es` version of their lib.

This is also reported in comments
https://github.com/vercel/next.js/pull/52148#discussion_r1251408484 and
https://github.com/vercel/next.js/pull/52148#issuecomment-1619563059

### How?

Use the non-ES version. Instead of importing from `antd/es` dir, we use
`antd/lib` dir. and also change `@ant-design/icons/` into
`@ant-design/icons/lib/icons/`

This `modularizeImports` config has also been used in my company's
project.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-07-05 22:03:46 -07:00
Lee Robinson
6527d29c8a
docs: Improve some of the error messages pages. (#52271)
Now that we've improved `/messages`
(https://github.com/vercel/next.js/pull/52038), we'd like to start
updating some of the content as well 🙏
2023-07-05 19:22:34 -07:00
Steven
525ffb4334
chore: remove experimental appDir: true from tests (#52291)
The experimental flag is no longer needed.

https://nextjs.org/blog/next-13-4
2023-07-05 19:17:29 -07:00
Luba Kravchenko
8ed2b27553
Handle 409s in fetch cache (#51652)
### What?
Adds 409 response handling for fetch cache

### Why?
So we stop making data cache requests when it returns 409 for a
specified amount of time

### How?
Set a module scope variable `rateLimitedUntil` that we check against
before making a request. If we receive a 409 then set `rateLimitedUntil`
to now() + either a specified retry-after value returned from the api or
60s (can make this something else)

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-07-05 19:01:27 -07:00
feikerwu
bd02b4db7c
docs: Add clearer instructions on the storage location of mdx-components files. (#52187)
Co-authored-by: Lee Robinson <me@leerob.io>
2023-07-05 18:55:12 -07:00
Jiachi Liu
927fc9e220
skip hot reload sync event for applying hmr updates (#52270)
### Issue

x-ref:
https://github.com/vercel/next.js/actions/runs/5469070005/jobs/9957658991?pr=52282#step:27:526
metadata tests are failing as flaky recently, then after digging into
it, noticed it as a hmr issue.

**Steps to repro with metadata test app**

The later (after the 1st one) visited page with client components
imports sometimes throw an full reload refresh warning
> Fast Refresh will perform a full reload when you edit a file that's
imported by modules
outside of the React rendering tree.

Turns out there's some unexpected hmr events when `"sync"` event is
triggered, and client tries to apply the updates but then failed. This
PR excludes the triggering by `"sync"` for RSC pages updates. `'sync'`
event with errors/warnings will still be handled and then `'built'`
event will be handled with hot reload updates

Possibly related to #40184
2023-07-05 17:06:11 -07:00
JJ Kasper
3fb3bbbcb3
Disable flakey turbopack env test (#52295)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04KC8A53T7/p1688583522551569?thread_ts=1688581436.174189&cid=C04KC8A53T7)
2023-07-05 17:05:31 -07:00
Jiachi Liu
0048908078
Remove legacy head.js in examples (#52292)
* Remove legacy `head.js` from examples and use `metadata` exports
instead
* Update the report template

---------
2023-07-05 16:42:36 -07:00
Jiachi Liu
f9a181342f
Remove the outdated error for find page dir (#52274)
Found this function is used by `nextra` and log unexpected warning sometimes

```
// node_modules/.pnpm/nextra@2.8.0_2yzqpfdqpxhuhtk2arnb2je2cq/node_modules/nextra/dist/index.js
// src/file-system.ts
var findPagesDirImport = __toESM(require("next/dist/lib/find-pages-dir.js"));
```
2023-07-05 23:31:59 +00:00
Steven
e27832665a
chore: update issue template option to "App Router" (#52287)
https://nextjs.org/docs/app
2023-07-05 22:56:43 +00:00
Shu Ding
267c2d29cd
Use 127.0.0.1 as the default host for the standalone server (#52283)
This helps getting rid of the

```
Error: connect ECONNREFUSED ::1:64696
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
  errno: -61,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '::1',
  port: 64696
}
```

error for me when running the standalone server. cc @ijjk.

I'm not sure if it's related to https://github.com/http-party/node-http-proxy/issues/835.

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-07-05 22:20:29 +00:00
Steven
31dee6f38a
chore: remove experimental appDir: true from examples (#52289)
The experimental flag is no longer needed.

https://nextjs.org/blog/next-13-4
2023-07-05 21:45:39 +00:00
nauvalazhar
8e1fa7ea19
docs: add a missing open brackets in a next/link custom component (#52178) 2023-07-05 17:01:20 -04:00
Steven
941757ffae
chore(docs): remove "Legacy" from Preview Mode (#52284)
[Some readers](https://twitter.com/madebymutual/status/1676515579362942976 ) are confused about the docs using the term [Legacy](https://en.wikipedia.org/wiki/Legacy_system) thinking it means [Deprecated](https://en.wikipedia.org/wiki/Deprecation).

Preview Mode only exists in Pages Router so technically both are legacy, but we don't need to call out Preview Mode specifically as legacy since we don't do that for any other Pages Router feature.

This PR removes the term "Legacy" to avoid confusion.
2023-07-05 20:23:27 +00:00
JJ Kasper
8dc0b1be61
Fix app cache enabling case (#52278)
Ensures we don't attempt using the wrong cache handler during build. 

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1688549526316949)
2023-07-05 12:52:16 -07:00
JJ Kasper
5046ee13aa
Revert "Fix stream cancellation in RenderResult.pipe() and sendResponse()" (#52277)
The test here seems to be failing after merge 

x-ref:
https://github.com/vercel/next.js/actions/runs/5467319221/jobs/9953529745
x-ref:
https://github.com/vercel/next.js/actions/runs/5467152519/jobs/9953132439

Reverts vercel/next.js#52157
2023-07-05 11:12:39 -07:00
JJ Kasper
9151362c07
Make tests result check more accurate (#52273)
This ensures we check all statuses properly as previously only one
success was required.

x-ref: https://github.com/vercel/next.js/pull/52272
x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1688573457803739)
2023-07-05 10:41:22 -07:00
JJ Kasper
dd0a9d033c
Revert "Update eslint-plugin-react-hooks to 5.0.0-canary-7118f5dd7-20230705" (#52272)
Reverts vercel/next.js#52268

x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1688573457803739)
2023-07-05 10:21:19 -07:00
Justin Ridgewell
ff1f75a873
Fix stream cancellation in RenderResult.pipe() and sendResponse() (#52157)
### What?

I've found 2 more spots that didn't properly cancel the streaming response when the client disconnects. This fixes `RenderResult.pipe()` (called during dynamic render results) and `sendResponse()` (used during Route Handlers using `nodejs` runtime).

It also (finally) adds tests for all the cases I'm aware of.

### Why?

To allow disconnecting from an AI service when a client disconnects. $$$

### How?

Just checks for `response.closed`, which will be closed when the client's connection disconnects.
2023-07-05 17:15:48 +00:00
Andrew Clark
9049c0f275
Update eslint-plugin-react-hooks to 5.0.0-canary-7118f5dd7-20230705 (#52268)
5.0.0-canary-7118f5dd7-20230705 includes a new [lint error for hook calls inside an async component](7118f5dd7b), a common mistake when refactoring Server Components to Client Components, or vice versa.

This updates the dependency in eslint-config-next.
2023-07-05 16:07:22 +00:00
Shu Ding
a8d09d73c1
Fix small memory leaks (#52257)
Fix a few KBs (depending on the tree state size) of leaked memory caused by closures. All the marked objects below are caused by `serverActionDispatcher` which are not cleaned up after SSR:

![CleanShot 2023-07-05 at 15 15 17@2x](https://github.com/vercel/next.js/assets/3676859/d6731830-146e-4433-9ab7-19ea878472cf)
2023-07-05 15:40:12 +00:00
OJ Kwon
6885b98d35
feat(turbopack): add crypto polyfill (#51622)
### What?

PR attempts to fix WEB-1214, provides a polyfill to globalThis.crypto.
2023-07-05 14:38:34 +00:00