Commit Graph

1310 Commits

Author SHA1 Message Date
Zack Tanner a74a58721a fix React 18 test failures (#80119)
Fixes failing assertions related to the forked React 18 tests.

[x-ref](https://github.com/vercel/next.js/actions/runs/15417191195/job/43385564776#step:34:533)
2025-06-03 16:00:18 -07:00
Jiachi Liu bc4b72df8e [devtool] fix explorer flag consuming and style (#80110) 2025-06-03 18:40:59 +02:00
Hamidreza Hanafi 669a8ca539 Fix(turbopack): Resolve experimentalDecorators from extended tsconfig (#79755)
Co-authored-by: Jude Gao <jude.gao@vercel.com>
2025-06-03 12:25:56 +02:00
Sebastian "Sebbie" Silbermann 4ab6eba5c0 [dev-overlay] Move Redbox open/close into dispatcher (#79698) 2025-05-27 23:16:19 +02:00
Sebastian "Sebbie" Silbermann c51300807e [dev-overlay] Show error overlay on any thrown value in /app (#79658)
May have been a leftover from earlier. 

We always consider any throw. Even without a sync stack, we might still have an async stack to show. And even if we have no stack at all, the message is still relevant. Basically, never hide errors.
2025-05-27 20:17:38 +02:00
Hendrik Liebau 05dc8408be Unflake Undefined default export test (#79632)
[flakiness
metric](https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20env%3Aci%20%40git.repository.id%3Agithub.com%2Fvercel%2Fnext.js%20%40test.service%3Anextjs%20%40test.status%3Afail%20%40test.name%3A%22Undefined%20default%20export%20should%20error%20when%20page%20component%20export%20is%20not%20valid%22%20%40git.branch%3Acanary&agg_m=count&agg_m_source=base&agg_t=count&currentTab=overview&eventStack=&fromUser=false&index=citest&start=1746962081472&end=1748258081472&paused=false)

The test's flakiness started to increase significantly on 5/21.

<img width="414" alt="Screenshot 2025-05-26 at 13 18 29"
src="https://github.com/user-attachments/assets/3996cbd1-4a54-412d-9578-317f967030fd"
/>

Using
[these](https://github.com/vercel/next.js/actions/runs/15249566684/job/42888664439?pr=79565)
[two](https://github.com/vercel/next.js/actions/runs/15251316578/job/42888825737?pr=79629)
test runs as examples, we can see that the `/_error` page takes quite a
long time to compile, which then leads to a timeout while waiting for
the `#__next` element on the error page to be present in the DOM.

Looking at the [canary release from this
day](https://github.com/vercel/next.js/releases/tag/v15.4.0-canary.45),
it might be related to #79260.

In fact, running the test before and after this PR uncovers a
significant increase in dev compilation times for the `/_error` page,
which is a pages router page.

<img width="230" alt="Screenshot 2025-05-26 at 13 27 23"
src="https://github.com/user-attachments/assets/00381ab1-3a75-4306-b184-8a14b906d1ff"
/>

We'll address this regression in a follow-up.
2025-05-26 12:14:08 +00:00
Zack Tanner b7a7752f14 de-flake ReactRefreshLogBox (app) (#79573)
This test is failing fairly consistently in CI. I suspect it's a timing
issue for when the error is thrown and when the redbox gets triggered.
2025-05-23 21:51:55 +00:00
Josh Story bc3045357b [dynamicIO] reimplement dynamicIO validation on prerender (#79414)
This updates the dynamic validation implementation to more closely
follow the pattern used in prerenders for dynamicIO + PPR. Now that PPR
is the only way to use dynamicIO we only have one implementation and the
validation should match it as much as possible.
2025-05-21 11:47:11 -07:00
Sebastian "Sebbie" Silbermann 100881542a [test] Use NEXT_TEST_CI when forking test in CI (#79354) 2025-05-21 20:29:19 +02:00
JJ Kasper d937203f39 Implement initial handler interface for pages routes (#79260)
Continuation of https://github.com/vercel/next.js/pull/78166 this
implements the `handler` interface for pages routes, This does not move
the response handling inside of the handler yet as that will be in a
follow-up PR to keep the changes isolated. This still returns the
`RenderResult` for the `base-server` to continue to handle.

Validated against `vercel/vercel` deploy tests here
https://github.com/vercel/vercel/pull/13349
2025-05-20 16:23:50 -07:00
Jiwon Choi d16d9f46b6 [TypeScript Plugin] Match method signature (someFunc(): void) type for client boundary warnings (#79144)
Best to be reviewed with "Hide whitespace".

### Why?

The props marked `(): any` bypassed the warning for non-serializable
props.

```tsx
'use client'

export function Comp({ onClick }: { onClick(): any }) {
  // ...
}
```

Added tests to prevent regression.

---------

Co-authored-by: Janka Uryga <lolzatu2@gmail.com>
2025-05-20 01:35:51 +02:00
Hendrik Liebau 2a95766744 Remove obsolete ppr configs from Dynamic IO tests (#79305)
Now that `ppr` is enabled by default when `dynamicIO` is enabled, we can remove the obsolete `ppr: true` configs from the Dynamic IO tests.
2025-05-19 16:52:03 +02:00
Janka Uryga 04bfbdab6e test: fix more Runtime/Recoverable Error flakiness in HMR (#79371)
Follow-up to #79254, there's one more test flaking with the same issue.

I pulled the label-ignoring logic out into

```ts
expect(browser).toDisplayRedbox('...', { label: false })
```

so that it's easy to find these later when we fix the underlying issue.
2025-05-19 14:46:47 +00:00
Hendrik Liebau 53933954e3 Enable PPR in Dynamic IO tests (#79301)
To prepare for an upcoming change where `ppr` will be enabled
automatically when `dynamicIO` is enabled, we're hard coding `ppr: true`
in the Dynamic IO tests with this PR. The non-PPR assertions are
subsequently removed, which makes up most of the changed lines.

We can now also exclude the tests in the PPR tests manifest, so that
they're not run twice in CI.

> [!NOTE]  
> This PR is best reviewed with hidden whitespace changes.
2025-05-17 20:50:29 +02:00
Jiwon Choi 3ecf087f10 [TypeScript Plugin] Moved the diagnostics' positions to the prop's type instead of the value for client-boundary warnings (#79193)
Best be reviewed with "Hide whitespace".

### Why?

Since it was matching `ts.isObjectBindingPattern`, which checks only the
destructured props:

![CleanShot 2025-05-14 at 12 17
25@2x](https://github.com/user-attachments/assets/44aaffd2-9276-486e-86ce-acb77d488ab0)

It didn't handle non-destructured:

![CleanShot 2025-05-14 at 12 17
34@2x](https://github.com/user-attachments/assets/23abc130-3e17-4f72-89a2-bc084841f52f)

Therefore, I think it's more natural to target the types, not the props
value, as the cause of this warning is actually the types:

![CleanShot 2025-05-14 at 12 18
00@2x](https://github.com/user-attachments/assets/0a5a64c8-1ac9-4b0f-8fe7-20e78db2acec)

![CleanShot 2025-05-14 at 12 17
53@2x](https://github.com/user-attachments/assets/72008c25-7d7b-46e4-8e2f-e52f01e50b80)

x-ref:
https://github.com/vercel/next.js/pull/79144#discussion_r2086941435

---------

Co-authored-by: Janka Uryga <lolzatu2@gmail.com>
2025-05-17 12:04:44 +02:00
Jiachi Liu 0ca32b2b4a [devtool] initial support for segment explorer (#78858) 2025-05-16 12:10:59 +08:00
Janka Uryga 733e4d6413 test: fix snapshots in failing tests (#79254) 2025-05-15 20:53:15 +00:00
Hendrik Liebau bc7ce5d68d Reland: Fix false-positive "use cache" misplacement error (#79222)
_Relanding #79151, now ignoring TS AST nodes when checking whether all
exported module items are async functions._

This fixes an error where we incorrectly showed the following compiler
error when using Turbopack:

```sh
Ecmascript file had an error
> 1 | 'use cache'
    | ^^^^^^^^^^^
  2 |
  3 | import { useStuff } from './client-module'
  4 |

The "use cache" directive must be at the top of the file.
```

The directive was regarded as not being at the top of the file, because
the React transform (`EcmascriptInputTransform::React`) injects a
variable declaration for React Refresh (e.g. `var _s =
__turbopack_context__.k.signature`) at the top of the file, before the
`"use cache"` directive.

We can fix this by ensuring that the server action transform (should
really be called "server _function_ transform") runs first.

As a consequence, the transform now needs to be able to parse JSX AST
nodes, which was already explicitly implemented.

closes NAR-130

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

-->
2025-05-15 13:06:28 +02:00
Jiwon Choi 53bb899fc4 [ts-next-plugin] test: add client-boundary test (#79194)
This PR added tests for Next.js TypeScript plugins, specific for client-boundary. Updated the readme and removed the legacy fixture.
2025-05-15 11:39:26 +02:00
Janka Uryga cb49b483f1 Reland "Ensure mangling is disabled for dev runtime builds (#75297)" (#79201)
Reapplies #75297

Also fixes some rspack tests which didn't await assertions properly so they might have looked like they're passing
2025-05-14 17:38:01 +02:00
Zack Tanner b304b45e3a bugfix (pages): assetPrefix should not cause hard nav in development (#79176)
In development when handling the page request, we are sending the
parsedUrl with the basePath stripped but not assetPrefix. As a result,
when setting an assetPrefix, the chunk would 404 which causes a hard
nav. It'd then recover and work correctly on subsequent navs.

This applies the exact same handling we had for basePath, but for
assetPrefix.

Fixes #77241
2025-05-14 08:07:28 -07:00
Donny/강동윤 de89c8cd01 Revert "Fix false-positive "use cache" misplacement error" (#79160)
Reverts vercel/next.js#79151

It caused a regression like this
```
export type Foo =
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Only async functions are allowed to be exported in a "use server" file.
```
2025-05-13 17:21:49 +00:00
Hendrik Liebau c1262aa970 Fix false-positive "use cache" misplacement error (#79151)
This fixes an error where we incorrectly showed the following compiler
error when using Turbopack:

```sh
Ecmascript file had an error
> 1 | 'use cache'
    | ^^^^^^^^^^^
  2 |
  3 | import { useStuff } from './client-module'
  4 |

The "use cache" directive must be at the top of the file.
```

The directive was regarded as not being at the top of the file, because
the React transform (`EcmascriptInputTransform::React`) injects a
variable declaration for React Refresh (e.g. `var _s =
__turbopack_context__.k.signature`) at the top of the file, before the
`"use cache"` directive.

We can fix this by ensuring that the server action transform (should
really be called "server _function_ transform") runs first.

As a consequence, the transform now needs to be able to parse JSX AST
nodes, which was already explicitly implemented.

closes NAR-130
2025-05-13 14:58:02 +02:00
Jiwon Choi a64f6b0735 test: replace duplicate test utils to next instance (#73624)
This PR replaces:
- `renderViaHTTP -> next.render`
- `cheerio.load -> next.render$`
- ~~`process.env.TURBOPACK` -> `isTurbopack`~~ (left as
`process.env.IS_TURBOPACK_TEST`)
2025-05-13 01:46:23 +02:00
Jiwon Choi f7c274328f test: remove unnecessary conditionals in error recovery tests (#73625)
This PR removed unnecessary basePath conditional checks.
2025-05-13 00:45:01 +02:00
Jiwon Choi d48881e4bf test: split hot module reload HMR test into multiple files (#79067)
Split long-running hot module reload hmr test to parallelize and reduce
CI time.

Port of https://github.com/vercel/next.js/pull/73620, confirmed no new
changes.
x-ref:
https://github.com/vercel/next.js/commits/canary/test/development/basic/hmr/hot-module-reload.test.ts
2025-05-13 00:39:41 +02:00
Jiwon Choi 7ac4eae058 test: split error recovery HMR test into multiple files (#79066)
Split long-running error recovery hmr test to parallelize and reduce CI
time.

Port of https://github.com/vercel/next.js/pull/73617, confirmed and
synced changes https://github.com/vercel/next.js/pull/78198,
https://github.com/vercel/next.js/pull/77892,
https://github.com/vercel/next.js/pull/76299,
https://github.com/vercel/next.js/pull/76290, and
https://github.com/vercel/next.js/pull/75882.

x-ref:
https://github.com/vercel/next.js/commits/canary/test/development/basic/hmr/error-recovery.test.ts
2025-05-13 00:04:58 +02:00
Jiwon Choi 2d4406312f test: split full reload HMR test into multiple files (#79065)
Split long-running full reload hmr test to parallelize and reduce CI time.

Port of https://github.com/vercel/next.js/pull/73619, confirmed change https://github.com/vercel/next.js/pull/78198 and synced.

x-ref: https://github.com/vercel/next.js/commits/canary/test/development/basic/hmr/full-reload.test.ts
2025-05-12 23:24:20 +02:00
Jiwon Choi e8a84e866c test: split basic HMR test into multiple files (#79064)
Split long-running basic hmr test to parallelize and reduce CI time.

As @huozhi mentioned at https://github.com/vercel/next.js/pull/73613#pullrequestreview-2485717304, the tests won't be separated to `__test__` dir but flattened out on the same level as the fixture dirs.

Port of https://github.com/vercel/next.js/pull/73616, confirmed no new changes.

x-ref: https://github.com/vercel/next.js/commits/canary/test/development/basic/hmr/basic.test.ts
2025-05-12 21:20:39 +02:00
Jiwon Choi 0625d0d116 [ts-next-plugin] test: add metadata warn no type test (#78505)
### Why?

This PR initiates the migration of manual testing of the Next.js TypeScript plugin to an automated language service plugin test. It replaced the existing metadata `missing-type-warning` fixture with the `warn-no-type` test (naming for consistency, such as future `error-on-client`).

### Testing Plan

This PR adds the tests and fixtures for the metadata plugin to **warn when no type is provided** for metadata config exports (`metadata` and `generateMetadata`).

1. The fixtures are tested into two categories: 1) "**has type**": expects no warning, and 2) "**no type**": expects a warning.
2. For "has type", the types are from `next` or custom.
3. Each section consists of inline exports and separate exports (`export { ... }`).
4. For the fixtures of `generateMetadata`, it is divided into a function, an arrow function, and a function expression divided with sync and async.

<details><summary>Structure Details</summary>
<p>

#### `metadata`

```
.
├── has-type/
│   ├── export-inline/
│   │   ├── from-next
│   │   └── from-others
│   └── export-separate/
│       ├── from-next
│       └── from-others
└── no-type/
    ├── export-inline
    └── export-separate
```

#### `gerenateMetadata`

```
.
├── has-type/
│   ├── export-inline/
│   │   ├── from-next/
│   │   │   ├── async/
│   │   │   │   ├── arrow-function
│   │   │   │   ├── function-declaration
│   │   │   │   └── function-expression
│   │   │   └── sync/
│   │   │       ├── arrow-function
│   │   │       ├── function-declaration
│   │   │       └── function-expression
│   │   └── from-others/
│   │       ├── async/
│   │       │   └── ...
│   │       └── sync/
│   │           └── ...
│   └── export-separate/
│       ├── from-next/
│       │   ├── async/
│       │   │   └── ...
│       │   └── sync/
│       │       └── ...
│       └── from-others/
│           ├── async/
│           │   └── ...
│           └── sync/
│               └── ...
└── no-type/
    ├── export-inline/
    │   ├── async/
    │   │   └── ...
    │   └── sync/
    │       └── ...
    └── export-separate/
        ├── async/
        │   └── ...
        └── sync/
            └── ...
```

</p>
</details> 

### Follow Up

The metadata currently has one more feature: an error when using metadata exports within Client Components.
2025-05-12 13:52:28 +02:00
Jiwon Choi 34c5d411dc [ts-next-plugin] add testing utils (#79079)
Ported from https://github.com/vercel/next.js/pull/78505, this PR adds testing utils and a basic log test for the Next.js TypeScript language service plugin.
2025-05-12 13:20:18 +02:00
Benjamin Woodruff 837e086479 chore(CI): Break pages-dir client-navigation dev tests into smaller parallelizable files/suites (#78787)
Jest can run different suites in parallel, but tests within the same suite must run sequentially in the same worker.

You don't want suites that are too small, because each suite requires relatively expensive repository setup, but you also don't want suites that are too large because it inhibits parallelism.

This is a big problem for arewerspackyet, where many of these test cases are currently failing. Each test can take up to 4 minutes to time out, so we easily time out the entire 90 minute long test runner job.

## Test plan

Tested by running all these tests in parallel with:

```
NEXT_TEST_MODE=dev HEADLESS=true node_modules/.bin/jest test/development/pages-dir/client-navigation
```

It completes in about 2m40s minutes on my machine.
2025-05-05 17:10:56 -07:00
Sebastian "Sebbie" Silbermann 8ea7d4bb35 [dev-overlay] Move error.name to label (#78198) 2025-04-25 11:00:58 +02:00
Jiwon Choi fd438787f3 misc: use correct capitals for React terms (#78445)
- `Client/Server Component`
- `React Hooks`

---------

Co-authored-by: Sebastian "Sebbie" Silbermann <sebastian.silbermann@vercel.com>
2025-04-23 21:50:55 +09:00
Jiachi Liu 5855bdc1fb [errors] fix edge server initial error is not sent via hmr (#78415) 2025-04-23 13:47:00 +02:00
Jiwon Choi ec2923acc2 [ts-next-plugin] test: add metadata and generateMetadata fixtures (#78409)
This PR added test fixtures for the Next.js TypeScript plugin for
metadata. The test should be done manually at the moment and will be
followed up to improve testing, e.g.
https://github.com/vercel/next.js/pull/78254#pullrequestreview-2783491648
2025-04-23 17:32:54 +09:00
Janka Uryga 4282bc6f91 remove BrowserInterface (#78308)
rip. you served a purpose once, but now you're just getting in the way. this improves typesafety quite a bit, because `BrowserInterface` had a whole bunch of random `any`s everywhere

also
- removes `evalAsync`. no idea why that was needed, but we're happily using promises in normal eval, so it can be dropped
- adds more safety to `chain`
2025-04-18 11:16:15 -07:00
Benjamin Woodruff 8d11384379 fix(turbo-tasks-fs): Update notify-rs, handle recursive symlinks in realpath implementation, add an e2e test for symlinked files (#78220)
While working on filesystem watching stuff, I saw that `notify-rs` had a new `with_follow_symlinks` flag, which seems very relevant to us and how we handle symlinks.

When looking to enable this, I noticed that we lacked e2e tests for symlinks. I added a few tests, but found lots of other bugs...

- I ran into https://github.com/vercel/next.js/discussions/77463#discussioncomment-12847522, which I documented, but am not fixing, because it's too far out of scope.
- I ran into a bug with realpath, which is fixed here.
2025-04-16 10:00:18 +02:00
Sebastian "Sebbie" Silbermann c334056eeb [dev-overlay] Add dedicated label for recoverable errors (#78186) 2025-04-16 09:49:35 +02:00
Sebastian "Sebbie" Silbermann d6f9e080d7 [dev-overlay] Stop appending wrong Owner Stacks to SSR-only shell errors (#77302) 2025-04-15 20:58:26 +02:00
Sebastian "Sebbie" Silbermann 96bfee2c81 [dev-overlay] Stop squashing hydration related errors in App Router (#78140) 2025-04-15 09:56:36 +02:00
Sebastian "Sebbie" Silbermann 307c40e5c4 [test] Assert on all errors in app/ hydration-error suite (#78132) 2025-04-15 09:29:21 +02:00
Sebastian "Sebbie" Silbermann 86fef73f3f [dev-overlay] Stop stashing React error details on error instances (#77975) 2025-04-14 09:42:43 +00:00
Sebastian "Sebbie" Silbermann 2b34bfac5f [test] Remove global styled-components install (#77782) 2025-04-10 12:52:47 +00:00
Sebastian "Sebbie" Silbermann 1ee500b01e [test] Use React 19.1 everywhere (#77895) 2025-04-10 14:39:55 +02:00
Sebastian "Sebbie" Silbermann 7a134ec8eb [test] Stop asserting on internal stackframes when features are working as intended (#78015) 2025-04-10 10:19:48 +00:00
Sebastian "Sebbie" Silbermann b9d65b8afe [test] Assert on all errors in Redbox matchers (#77907) 2025-04-10 10:00:42 +02:00
Tobias Koppers 664110c188 Turbopack: read asset entries strongly consistent (#77974)
### What?

Avoid eventual consistent results influencing the map state.
2025-04-09 18:38:57 +02:00
Janka Uryga c0b7f72bb9 compile-time error for useLinkStatus imports in server components (#77962)
Adds `useLinkStatus` to the list of APIs that can't be imported in
server components.
2025-04-09 09:17:48 +00:00
Donny/강동윤 082b2dd19d build: Update swc_core to v21.0.1 (#77918)
### What?

Update swc_core to the latest version. ChangeLog: https://github.com/swc-project/swc/compare/swc_core%40v19.0.0...swc_core%40v21.0.1

### Why?

To keep in sync & apply https://github.com/swc-project/swc/pull/10314

### How?

Closes NDX-967
2025-04-08 21:41:47 +09:00