Skip to content

Commit

Permalink
Merge branch 'canary' into update-with-styletron-example
Browse files Browse the repository at this point in the history
  • Loading branch information
PapatMayuri authored Nov 29, 2024
2 parents 72264ac + 34f633b commit 5ab30d1
Show file tree
Hide file tree
Showing 51 changed files with 808 additions and 402 deletions.
10 changes: 5 additions & 5 deletions errors/next-dynamic-api-wrong-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ Example:
```diff filename="app/page.js"
import { cookies } from 'next/headers'

- const cookieStore = cookies()
export default function Page() {
+ const cookieStore = cookies()
- const cookieStore = await cookies()
export default async function Page() {
+ const cookieStore = await cookies()
return ...
}
```

```diff filename="app/foo/route.js"
import { headers } from 'next/headers'

- const headersList = headers()
- const headersList = await headers()
export async function GET() {
+ const headersList = headers()
+ const headersList = await headers()
return ...
}
```
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "15.0.4-canary.30"
"version": "15.0.4-canary.31"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"description": "ESLint configuration used by Next.js.",
"main": "index.js",
"license": "MIT",
Expand All @@ -10,7 +10,7 @@
},
"homepage": "https://nextjs.org/docs/app/api-reference/config/eslint#eslint-config",
"dependencies": {
"@next/eslint-plugin-next": "15.0.4-canary.30",
"@next/eslint-plugin-next": "15.0.4-canary.31",
"@rushstack/eslint-patch": "^1.10.3",
"@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0",
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"description": "ESLint plugin for Next.js.",
"main": "dist/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@next/font",
"private": true,
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"private": true,
"scripts": {
"clean": "node ../../scripts/rm.mjs native",
Expand Down
14 changes: 7 additions & 7 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -97,7 +97,7 @@
]
},
"dependencies": {
"@next/env": "15.0.4-canary.30",
"@next/env": "15.0.4-canary.31",
"@swc/counter": "0.1.3",
"@swc/helpers": "0.5.13",
"busboy": "1.6.0",
Expand Down Expand Up @@ -161,11 +161,11 @@
"@jest/types": "29.5.0",
"@mswjs/interceptors": "0.23.0",
"@napi-rs/triples": "1.2.0",
"@next/font": "15.0.4-canary.30",
"@next/polyfill-module": "15.0.4-canary.30",
"@next/polyfill-nomodule": "15.0.4-canary.30",
"@next/react-refresh-utils": "15.0.4-canary.30",
"@next/swc": "15.0.4-canary.30",
"@next/font": "15.0.4-canary.31",
"@next/polyfill-module": "15.0.4-canary.31",
"@next/polyfill-nomodule": "15.0.4-canary.31",
"@next/react-refresh-utils": "15.0.4-canary.31",
"@next/swc": "15.0.4-canary.31",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "1.41.2",
"@swc/core": "1.9.2-nightly-20241111.1",
Expand Down
10 changes: 6 additions & 4 deletions packages/next/src/server/request/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ export function connection(): Promise<void> {
const workUnitStore = workUnitAsyncStorage.getStore()

if (workStore) {
if (workUnitStore && workUnitStore.phase === 'after') {
throw new Error(
`Route ${workStore.route} used "connection" inside "unstable_after(...)". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but "unstable_after(...)" executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/unstable_after`
)
}

if (workStore.forceStatic) {
// When using forceStatic we override all other logic and always just return an empty
// headers object without tracking
Expand All @@ -33,10 +39,6 @@ export function connection(): Promise<void> {
throw new Error(
`Route ${workStore.route} used "connection" inside a function cached with "unstable_cache(...)". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but caches must be able to be produced before a Request so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`
)
} else if (workUnitStore.phase === 'after') {
throw new Error(
`Route ${workStore.route} used "connection" inside "unstable_after(...)". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual Request, but "unstable_after(...)" executes after the request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/unstable_after`
)
}
}
if (workStore.dynamicShouldError) {
Expand Down
11 changes: 7 additions & 4 deletions packages/next/src/server/request/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ export function cookies(): Promise<ReadonlyRequestCookies> {
const workUnitStore = workUnitAsyncStorage.getStore()

if (workStore) {
if (workUnitStore && workUnitStore.phase === 'after') {
throw new Error(
// TODO(after): clarify that this only applies to pages?
`Route ${workStore.route} used "cookies" inside "unstable_after(...)". This is not supported. If you need this data inside an "unstable_after" callback, use "cookies" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/unstable_after`
)
}

if (workStore.forceStatic) {
// When using forceStatic we override all other logic and always just return an empty
// cookies object without tracking
Expand All @@ -68,10 +75,6 @@ export function cookies(): Promise<ReadonlyRequestCookies> {
throw new Error(
`Route ${workStore.route} used "cookies" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "cookies" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`
)
} else if (workUnitStore.phase === 'after') {
throw new Error(
`Route ${workStore.route} used "cookies" inside "unstable_after(...)". This is not supported. If you need this data inside an "unstable_after" callback, use "cookies" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/unstable_after`
)
}
}
if (workStore.dynamicShouldError) {
Expand Down
10 changes: 6 additions & 4 deletions packages/next/src/server/request/headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ export function headers(): Promise<ReadonlyHeaders> {
const workUnitStore = workUnitAsyncStorage.getStore()

if (workStore) {
if (workUnitStore && workUnitStore.phase === 'after') {
throw new Error(
`Route ${workStore.route} used "headers" inside "unstable_after(...)". This is not supported. If you need this data inside an "unstable_after" callback, use "headers" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/unstable_after`
)
}

if (workStore.forceStatic) {
// When using forceStatic we override all other logic and always just return an empty
// headers object without tracking
Expand All @@ -73,10 +79,6 @@ export function headers(): Promise<ReadonlyHeaders> {
throw new Error(
`Route ${workStore.route} used "headers" inside a function cached with "unstable_cache(...)". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use "headers" outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/app/api-reference/functions/unstable_cache`
)
} else if (workUnitStore.phase === 'after') {
throw new Error(
`Route ${workStore.route} used "headers" inside "unstable_after(...)". This is not supported. If you need this data inside an "unstable_after" callback, use "headers" outside of the callback. See more info here: https://nextjs.org/docs/canary/app/api-reference/functions/unstable_after`
)
}
}
if (workStore.dynamicShouldError) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/third-parties/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/third-parties",
"version": "15.0.4-canary.30",
"version": "15.0.4-canary.31",
"repository": {
"url": "vercel/next.js",
"directory": "packages/third-parties"
Expand All @@ -26,7 +26,7 @@
"third-party-capital": "1.0.20"
},
"devDependencies": {
"next": "15.0.4-canary.30",
"next": "15.0.4-canary.31",
"outdent": "0.8.0",
"prettier": "2.5.1",
"typescript": "5.6.3"
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ describe('error-ignored-frames', () => {
files: __dirname,
})

// TODO: remove this when reactOwnerStack is enabled by default
if (process.env.__NEXT_EXPERIMENTAL_PPR === 'true') {
if (
// TODO: remove this when reactOwnerStack is enabled by default
// Since PPR mode is just going to add owner stack, skip this test for now
it('skip ppr test', () => {})
process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ||
// Skip react 18 test as the call stacks are different
process.env.NEXT_TEST_REACT_VERSION === '18.3.1'
) {
it('skip test', () => {})
return
}

Expand Down
12 changes: 12 additions & 0 deletions test/e2e/app-dir/next-after-app-api-usage/app/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js',
}

export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { cookies, headers } from 'next/headers'
import { unstable_after as after, connection } from 'next/server'

export function testRequestAPIs() {
after(async () => {
try {
await headers()
console.log('headers(): ok')
} catch (err) {
console.error(err)
}
})

after(async () => {
try {
await cookies()
console.log('cookies(): ok')
} catch (err) {
console.error(err)
}
})

after(async () => {
try {
await connection()
console.log('connection(): ok')
} catch (err) {
console.error(err)
}
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { testRequestAPIs } from '../helpers'

export const dynamic = 'error'

export default async function Page() {
testRequestAPIs()
return null
}
Loading

0 comments on commit 5ab30d1

Please sign in to comment.