Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "16.3.1-canary.20"
"version": "16.3.1-canary.21"
}
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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/devlow-bench/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@vercel/devlow-bench",
"private": true,
"version": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"description": "Benchmarking tool for the developer workflow",
"repository": {
"type": "git",
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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"description": "ESLint configuration used by Next.js.",
"license": "MIT",
"repository": {
Expand All @@ -12,7 +12,7 @@
"dist"
],
"dependencies": {
"@next/eslint-plugin-next": "16.3.1-canary.20",
"@next/eslint-plugin-next": "16.3.1-canary.21",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-import": "^2.32.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-internal/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@next/eslint-plugin-internal",
"private": true,
"version": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"description": "ESLint plugin for working on Next.js.",
"exports": {
".": "./src/eslint-plugin-internal.js"
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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"description": "ESLint plugin for Next.js.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-playwright/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/playwright",
"version": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-playwright"
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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"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-routing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/routing",
"version": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-rspack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-rspack",
"version": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-rspack"
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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"private": true,
"files": [
"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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -100,7 +100,7 @@
]
},
"dependencies": {
"@next/env": "16.3.1-canary.20",
"@next/env": "16.3.1-canary.21",
"@swc/helpers": "0.5.23",
"baseline-browser-mapping": "^2.9.19",
"caniuse-lite": "^1.0.30001579",
Expand Down Expand Up @@ -164,11 +164,11 @@
"@modelcontextprotocol/sdk": "1.18.1",
"@mswjs/interceptors": "0.42.0",
"@napi-rs/triples": "1.2.0",
"@next/font": "16.3.1-canary.20",
"@next/polyfill-module": "16.3.1-canary.20",
"@next/polyfill-nomodule": "16.3.1-canary.20",
"@next/react-refresh-utils": "16.3.1-canary.20",
"@next/swc": "16.3.1-canary.20",
"@next/font": "16.3.1-canary.21",
"@next/polyfill-module": "16.3.1-canary.21",
"@next/polyfill-nomodule": "16.3.1-canary.21",
"@next/react-refresh-utils": "16.3.1-canary.21",
"@next/swc": "16.3.1-canary.21",
"@opentelemetry/api": "1.6.0",
"@playwright/test": "1.61.0",
"@rspack/core": "1.6.7",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ActionAsyncStorage } from './action-async-storage.external'
import { createAsyncLocalStorage } from './async-local-storage'
import { getOrCreateGlobalAsyncLocalStorage } from './async-local-storage'

export const actionAsyncStorageInstance: ActionAsyncStorage =
createAsyncLocalStorage()
getOrCreateGlobalAsyncLocalStorage('action-async-storage')
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AfterTaskAsyncStorage } from './after-task-async-storage.external'
import { createAsyncLocalStorage } from './async-local-storage'
import { getOrCreateGlobalAsyncLocalStorage } from './async-local-storage'

export const afterTaskAsyncStorageInstance: AfterTaskAsyncStorage =
createAsyncLocalStorage()
getOrCreateGlobalAsyncLocalStorage('after-task-async-storage')
37 changes: 37 additions & 0 deletions packages/next/src/server/app-render/async-local-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,43 @@ export function createAsyncLocalStorage<
return new FakeAsyncLocalStorage()
}

/**
* Returns the storage registered under `name`, and creates it on first use.
*
* These storages must be singletons within a realm. A store that is entered
* through one reference to a storage must be readable through every other
* reference to it. If it is not, code that runs inside the scope sees no store
* at all. Module identity does not guarantee this. A realm can evaluate the
* same `next` file more than once if the package is reachable through more than
* one path, and then each evaluation creates a storage of its own. A global
* symbol keeps the singleton intact for any number of copies. Worker threads
* and edge sandboxes still get separate storages, because each of them has its
* own `globalThis`.
*
* Module identity broke this way in `next dev`. A bug in Node's
* `fs.realpathSync` can return a path with its symlinks unresolved, and the
* module loader keys the module cache on that path. On a pnpm install it then
* resolves `next/dist/...` through the `node_modules/next` symlink instead of
* the real path, so the file is evaluated a second time. See
* https://github.com/nodejs/node/pull/65113. Node versions without that fix
* stay affected.
*
* The key includes the Next.js version, so two different versions of Next.js in
* the same realm keep separate storages. Their store shapes might not be
* compatible.
*/
export function getOrCreateGlobalAsyncLocalStorage<Store extends {}>(
name: string
): AsyncLocalStorage<Store> {
const key = Symbol.for(`@next/${name}@${process.env.__NEXT_VERSION}`)

const globalStore = globalThis as typeof globalThis & {
[key: symbol]: AsyncLocalStorage<Store> | undefined
}

return (globalStore[key] ??= createAsyncLocalStorage<Store>())
}

export function bindSnapshot<T>(
// WARNING: Don't pass a named function to this argument! See: https://github.com/facebook/react/pull/34911
fn: T
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createAsyncLocalStorage } from './async-local-storage'
import { getOrCreateGlobalAsyncLocalStorage } from './async-local-storage'
import type { ConsoleAsyncStorage } from './console-async-storage.external'

export const consoleAsyncStorageInstance: ConsoleAsyncStorage =
createAsyncLocalStorage()
getOrCreateGlobalAsyncLocalStorage('console-async-storage')
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createAsyncLocalStorage } from './async-local-storage'
import { getOrCreateGlobalAsyncLocalStorage } from './async-local-storage'
import type { DynamicAccessStorage } from './dynamic-access-async-storage.external'

export const dynamicAccessAsyncStorageInstance: DynamicAccessStorage =
createAsyncLocalStorage()
getOrCreateGlobalAsyncLocalStorage('dynamic-access-async-storage')
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { WorkAsyncStorage } from './work-async-storage.external'
import { createAsyncLocalStorage } from './async-local-storage'
import { getOrCreateGlobalAsyncLocalStorage } from './async-local-storage'

export const workAsyncStorageInstance: WorkAsyncStorage =
createAsyncLocalStorage()
getOrCreateGlobalAsyncLocalStorage('work-async-storage')
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createAsyncLocalStorage } from './async-local-storage'
import { getOrCreateGlobalAsyncLocalStorage } from './async-local-storage'
import type { WorkUnitAsyncStorage } from './work-unit-async-storage.external'

export const workUnitAsyncStorageInstance: WorkUnitAsyncStorage =
createAsyncLocalStorage()
getOrCreateGlobalAsyncLocalStorage('work-unit-async-storage')
13 changes: 2 additions & 11 deletions packages/next/src/server/lib/trace/request-insights-identity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AsyncLocalStorage } from 'async_hooks'
import type { RequestInsightKind } from '../../../next-devtools/shared/request-insights'
import { createAsyncLocalStorage } from '../../app-render/async-local-storage'
import { getOrCreateGlobalAsyncLocalStorage } from '../../app-render/async-local-storage'

export type RequestInsightsIdentity = {
requestId: string
Expand All @@ -12,17 +12,8 @@ export type RequestInsightsIdentity = {
// This storage covers the part of BaseServer request handling that runs before
// App Render creates workAsyncStorage. Once available, workStore remains the
// primary identity source for locally recorded spans.
const REQUEST_INSIGHTS_IDENTITY_STORAGE_KEY = Symbol.for(
'@next/request-insights-identity-storage'
)

function getRequestInsightsIdentityStorage(): AsyncLocalStorage<RequestInsightsIdentity> {
const globalStore = globalThis as typeof globalThis & {
[REQUEST_INSIGHTS_IDENTITY_STORAGE_KEY]?: AsyncLocalStorage<RequestInsightsIdentity>
}

return (globalStore[REQUEST_INSIGHTS_IDENTITY_STORAGE_KEY] ??=
createAsyncLocalStorage())
return getOrCreateGlobalAsyncLocalStorage('request-insights-identity-storage')
}

export function runWithRequestInsightsIdentity<T>(
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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"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": "16.3.1-canary.20",
"version": "16.3.1-canary.21",
"repository": {
"url": "vercel/next.js",
"directory": "packages/third-parties"
Expand All @@ -26,7 +26,7 @@
"third-party-capital": "1.0.20"
},
"devDependencies": {
"next": "16.3.1-canary.20",
"next": "16.3.1-canary.21",
"outdent": "0.8.0",
"prettier": "2.5.1",
"typescript": "6.0.2"
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.

Loading
Loading