Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
a3d875e0
Unverified
Commit
a3d875e0
authored
Jul 14, 2025
by
Hendrik Liebau
Committed by
GitHub
Jul 14, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable `@typescript-eslint/switch-exhaustiveness-check` rule (#81583)
parent
6430cbc9
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
212 additions
and
259 deletions
+212
-259
.eslintrc.cli.json
.eslintrc.cli.json
+2
-1
no-typos.ts
packages/eslint-plugin-next/src/rules/no-typos.ts
+4
-2
entries.ts
packages/next/src/build/entries.ts
+3
-5
handle-entrypoints.ts
packages/next/src/build/handle-entrypoints.ts
+3
-1
options.ts
packages/next/src/build/swc/options.ts
+13
-10
webpack-config.ts
packages/next/src/build/webpack-config.ts
+2
-0
hot-reloader-app.tsx
...next/src/client/dev/hot-reloader/app/hot-reloader-app.tsx
+1
-0
hot-reloader-pages.ts
...t/src/client/dev/hot-reloader/pages/hot-reloader-pages.ts
+6
-3
console.ts
packages/next/src/client/lib/console.ts
+6
-0
page-bootstrap.ts
packages/next/src/client/page-bootstrap.ts
+14
-2
fetch.ts
packages/next/src/experimental/testmode/fetch.ts
+3
-2
resolve-metadata.ts
packages/next/src/lib/metadata/resolve-metadata.ts
+29
-8
resolve-opengraph.ts
...ages/next/src/lib/metadata/resolvers/resolve-opengraph.ts
+4
-1
metadata-types.ts
packages/next/src/lib/metadata/types/metadata-types.ts
+2
-2
diagnosticFormatter.ts
packages/next/src/lib/typescript/diagnosticFormatter.ts
+6
-14
runTypeCheck.ts
packages/next/src/lib/typescript/runTypeCheck.ts
+5
-8
use-overlay-reducer.ts
...ext-devtools/dev-overlay/storybook/use-overlay-reducer.ts
+37
-4
app-render-prerender-utils.ts
.../next/src/server/app-render/app-render-prerender-utils.ts
+0
-162
app-render.tsx
packages/next/src/server/app-render/app-render.tsx
+3
-12
csrf-protection.ts
packages/next/src/server/app-render/csrf-protection.ts
+1
-0
receive-logs.ts
packages/next/src/server/dev/browser-logs/receive-logs.ts
+23
-5
hot-reloader-types.ts
packages/next/src/server/dev/hot-reloader-types.ts
+0
-6
log-requests.ts
packages/next/src/server/dev/log-requests.ts
+4
-1
turbopack-utils.ts
packages/next/src/server/dev/turbopack-utils.ts
+3
-1
patch-fetch.ts
packages/next/src/server/lib/patch-fetch.ts
+10
-4
filesystem.ts
packages/next/src/server/lib/router-utils/filesystem.ts
+7
-1
console-dev.tsx
...xt/src/server/node-environment-extensions/console-dev.tsx
+10
-1
utils.ts
packages/next/src/server/response-cache/utils.ts
+4
-1
module.ts
packages/next/src/server/route-modules/app-route/module.ts
+7
-2
No files found.
.eslintrc.cli.json
View file @
a3d875e0
...
...
@@ -20,7 +20,8 @@
//
.eslintrc.json
for
the
matching
files.
"rules"
:
{
//
TODO
:
enable
in
follow-up
PR
"@typescript-eslint/no-floating-promises"
:
"off"
"@typescript-eslint/no-floating-promises"
:
"off"
,
"@typescript-eslint/switch-exhaustiveness-check"
:
"error"
}
}
]
...
...
packages/eslint-plugin-next/src/rules/no-typos.ts
View file @
a3d875e0
...
...
@@ -98,9 +98,11 @@ export = defineRule({
})
break
}
default
:
{
case
'ClassDeclaration'
:
// We don't need to check typos in class declarations.
break
}
default
:
decl
satisfies
never
}
return
},
...
...
packages/next/src/build/entries.ts
View file @
a3d875e0
...
...
@@ -865,7 +865,7 @@ export function finalizeEntrypoint({
isServerComponent
,
hasAppDir
,
}:
{
compilerType
?
:
CompilerNameValues
compilerType
:
CompilerNameValues
name
:
string
value
:
ObjectValue
<
webpack
.
EntryObject
>
isServerComponent
?:
boolean
...
...
@@ -958,9 +958,7 @@ export function finalizeEntrypoint({
...
entry
,
}
}
default
:
{
// Should never happen.
throw
new
Error
(
'Invalid compiler type'
)
}
default
:
return
compilerType
satisfies
never
}
}
packages/next/src/build/handle-entrypoints.ts
View file @
a3d875e0
...
...
@@ -33,9 +33,11 @@ export async function rawEntrypointsToEntrypoints(
app
.
set
(
route
.
originalName
,
route
)
break
}
default
:
case
'conflict'
:
Log
.
info
(
`skipping
${
pathname
}
(
${
route
.
type
}
)`
)
break
default
:
route
satisfies
never
}
}
...
...
packages/next/src/build/swc/options.ts
View file @
a3d875e0
...
...
@@ -276,16 +276,19 @@ function getEmotionOptions(
return
null
}
let
autoLabel
=
!!
development
switch
(
typeof
emotionConfig
===
'object'
&&
emotionConfig
.
autoLabel
)
{
case
'never'
:
autoLabel
=
false
break
case
'always'
:
autoLabel
=
true
break
case
'dev-only'
:
default
:
break
if
(
typeof
emotionConfig
===
'object'
&&
emotionConfig
.
autoLabel
)
{
switch
(
emotionConfig
.
autoLabel
)
{
case
'never'
:
autoLabel
=
false
break
case
'always'
:
autoLabel
=
true
break
case
'dev-only'
:
break
default
:
emotionConfig
.
autoLabel
satisfies
never
}
}
return
{
enabled
:
true
,
...
...
packages/next/src/build/webpack-config.ts
View file @
a3d875e0
...
...
@@ -1947,6 +1947,8 @@ export default async function getBaseWebpackConfig(
case
WEBPACK_LAYERS
.
actionBrowser
:
runtime
=
'app-page'
break
case
null
:
case
undefined
:
default
:
runtime
=
'pages'
}
...
...
packages/next/src/client/dev/hot-reloader/app/hot-reloader-app.tsx
View file @
a3d875e0
...
...
@@ -441,6 +441,7 @@ function processMessage(
return
}
default
:
{
obj
satisfies
never
}
}
}
...
...
packages/next/src/client/dev/hot-reloader/pages/hot-reloader-pages.ts
View file @
a3d875e0
...
...
@@ -361,13 +361,16 @@ function processMessage(obj: HMR_ACTION_TYPES) {
dispatcher
.
onRefresh
()
break
}
default
:
{
case
HMR_ACTIONS_SENT_TO_BROWSER
.
ADDED_PAGE
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
REMOVED_PAGE
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
RELOAD_PAGE
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
DEV_PAGES_MANIFEST_UPDATE
:
if
(
customHmrEventHandler
)
{
customHmrEventHandler
(
obj
)
break
}
break
}
default
:
obj
satisfies
never
}
}
...
...
packages/next/src/client/lib/console.ts
View file @
a3d875e0
...
...
@@ -48,6 +48,12 @@ function formatObject(arg: unknown, depth: number) {
}
case
'string'
:
return
JSON
.
stringify
(
arg
)
case
'number'
:
case
'bigint'
:
case
'boolean'
:
case
'symbol'
:
case
'undefined'
:
case
'function'
:
default
:
return
String
(
arg
)
}
...
...
packages/next/src/client/page-bootstrap.ts
View file @
a3d875e0
...
...
@@ -52,8 +52,20 @@ export function pageBootstrap(assetPrefix: string) {
})
break
}
default
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
ADDED_PAGE
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
REMOVED_PAGE
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
SERVER_COMPONENT_CHANGES
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
SYNC
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
BUILT
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
BUILDING
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
TURBOPACK_MESSAGE
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
TURBOPACK_CONNECTED
:
case
HMR_ACTIONS_SENT_TO_BROWSER
.
ISR_MANIFEST
:
// Most of these action types are handled in
// src/client/dev/hot-reloader/pages/hot-reloader-pages.ts
break
default
:
payload
satisfies
never
}
}
else
if
(
'event'
in
payload
)
{
switch
(
payload
.
event
)
{
...
...
@@ -116,7 +128,7 @@ export function pageBootstrap(assetPrefix: string) {
break
}
default
:
break
payload
satisfies
never
}
}
})
...
...
packages/next/src/experimental/testmode/fetch.ts
View file @
a3d875e0
...
...
@@ -117,10 +117,11 @@ export async function handleFetch(
throw
new
Error
(
`Proxy request aborted [
${
request
.
method
}
${
request
.
url
}
]`
)
case
'fetch'
:
return
buildResponse
(
proxyResponse
)
default
:
break
return
api
satisfies
never
}
return
buildResponse
(
proxyResponse
)
}
export
function
interceptFetch
(
originalFetch
:
Fetch
)
{
...
...
packages/next/src/lib/metadata/resolve-metadata.ts
View file @
a3d875e0
...
...
@@ -269,6 +269,7 @@ async function mergeMetadata(
break
}
// directly assign fields that fallback to null
case
'abstract'
:
case
'applicationName'
:
case
'description'
:
case
'generator'
:
...
...
@@ -290,18 +291,29 @@ async function mergeMetadata(
target
.
metadataBase
=
metadataBase
break
default
:
{
if
(
(
key
===
'viewport'
||
key
===
'themeColor'
||
key
===
'colorScheme'
)
&&
source
[
key
]
!=
null
)
{
case
'apple-touch-fullscreen'
:
{
buildState
.
warnings
.
add
(
`Use appleWebApp instead\nRead more: https://nextjs.org/docs/app/api-reference/functions/generate-metadata`
)
break
}
case
'apple-touch-icon-precomposed'
:
{
buildState
.
warnings
.
add
(
`Use icons.apple instead\nRead more: https://nextjs.org/docs/app/api-reference/functions/generate-metadata`
)
break
}
case
'themeColor'
:
case
'colorScheme'
:
case
'viewport'
:
if
(
source
[
key
]
!=
null
)
{
buildState
.
warnings
.
add
(
`Unsupported metadata
${
key
}
is configured in metadata export in
${
route
}
. Please move it to viewport export instead.\nRead more: https://nextjs.org/docs/app/api-reference/functions/generate-viewport`
)
}
break
default
:
{
key
satisfies
never
}
}
}
...
...
@@ -335,11 +347,20 @@ function mergeViewport({
case
'colorScheme'
:
target
.
colorScheme
=
source
.
colorScheme
||
null
break
default
:
case
'width'
:
case
'height'
:
case
'initialScale'
:
case
'minimumScale'
:
case
'maximumScale'
:
case
'userScalable'
:
case
'viewportFit'
:
case
'interactiveWidget'
:
// always override the target with the source
// @ts-ignore viewport properties
target
[
key
]
=
source
[
key
]
break
default
:
key
satisfies
never
}
}
}
...
...
packages/next/src/lib/metadata/resolvers/resolve-opengraph.ts
View file @
a3d875e0
...
...
@@ -247,8 +247,11 @@ export const resolveTwitter: FieldResolverExtraArgs<
resolved
.
app
=
resolved
.
app
||
{}
break
}
default
:
case
'summary'
:
case
'summary_large_image'
:
break
default
:
resolved
satisfies
never
}
}
...
...
packages/next/src/lib/metadata/types/metadata-types.ts
View file @
a3d875e0
...
...
@@ -7,14 +7,14 @@
export
interface
DeprecatedMetadataFields
{
/**
* Deprecated options that have a preferred method
* @deprecated Use app
WebApp to configure mobile-web-app-capable which provides
* @deprecated Use app
leWebApp instead
*/
'apple-touch-fullscreen'
?:
never
|
undefined
/**
* Obsolete since iOS 7.
* @see https://web.dev/apple-touch-icon/
* @deprecated
use icons.apple or
instead
* @deprecated
Use icons.apple
instead
*/
'apple-touch-icon-precomposed'
?:
never
|
undefined
}
...
...
packages/next/src/lib/typescript/diagnosticFormatter.ts
View file @
a3d875e0
import
{
bold
,
cyan
,
red
,
yellow
}
from
'../picocolors'
import
path
from
'path'
// eslint typescript has a bug with TS enums
/* eslint-disable no-shadow */
export
enum
DiagnosticCategory
{
Warning
=
0
,
Error
=
1
,
Suggestion
=
2
,
Message
=
3
,
}
function
getFormattedLinkDiagnosticMessageText
(
diagnostic
:
import
(
'typescript'
).
Diagnostic
)
{
...
...
@@ -339,21 +330,22 @@ export function getFormattedDiagnostic(
const
category
=
diagnostic
.
category
switch
(
category
)
{
// Warning
case
DiagnosticCategory
.
Warning
:
{
case
ts
.
DiagnosticCategory
.
Warning
:
{
message
+=
yellow
(
bold
(
'Type warning'
))
+
': '
break
}
// Error
case
DiagnosticCategory
.
Error
:
{
case
ts
.
DiagnosticCategory
.
Error
:
{
message
+=
red
(
bold
(
'Type error'
))
+
': '
break
}
// 2 = Suggestion, 3 = Message
case
DiagnosticCategory
.
Suggestion
:
case
DiagnosticCategory
.
Message
:
default
:
{
case
ts
.
DiagnosticCategory
.
Suggestion
:
case
ts
.
DiagnosticCategory
.
Message
:
message
+=
cyan
(
bold
(
category
===
2
?
'Suggestion'
:
'Info'
))
+
': '
break
default
:
{
category
satisfies
never
}
}
...
...
packages/next/src/lib/typescript/runTypeCheck.ts
View file @
a3d875e0
import
path
from
'path'
import
{
DiagnosticCategory
,
getFormattedDiagnostic
,
}
from
'./diagnosticFormatter'
import
{
getFormattedDiagnostic
}
from
'./diagnosticFormatter'
import
{
getTypeScriptConfiguration
}
from
'./getTypeScriptConfiguration'
import
{
getRequiredConfiguration
}
from
'./writeConfigurationDefaults'
...
...
@@ -91,14 +88,14 @@ export async function runTypeCheck(
const
firstError
=
allDiagnostics
.
find
(
(
d
)
=>
d
.
category
===
DiagnosticCategory
.
Error
&&
Boolean
(
d
.
file
)
)
??
allDiagnostics
.
find
((
d
)
=>
d
.
category
===
DiagnosticCategory
.
Error
)
(
d
)
=>
d
.
category
===
ts
.
DiagnosticCategory
.
Error
&&
Boolean
(
d
.
file
)
)
??
allDiagnostics
.
find
((
d
)
=>
d
.
category
===
ts
.
DiagnosticCategory
.
Error
)
// In test mode, we want to check all diagnostics, not just the first one.
if
(
process
.
env
.
__NEXT_TEST_MODE
)
{
if
(
firstError
)
{
const
allErrors
=
allDiagnostics
.
filter
((
d
)
=>
d
.
category
===
DiagnosticCategory
.
Error
)
.
filter
((
d
)
=>
d
.
category
===
ts
.
DiagnosticCategory
.
Error
)
.
map
(
(
d
)
=>
'[Test Mode] '
+
...
...
@@ -123,7 +120,7 @@ export async function runTypeCheck(
}
const
warnings
=
allDiagnostics
.
filter
((
d
)
=>
d
.
category
===
DiagnosticCategory
.
Warning
)
.
filter
((
d
)
=>
d
.
category
===
ts
.
DiagnosticCategory
.
Warning
)
.
map
((
d
)
=>
getFormattedDiagnostic
(
ts
,
baseDir
,
distDir
,
d
,
isAppDirEnabled
)
)
...
...
packages/next/src/next-devtools/dev-overlay/storybook/use-overlay-reducer.ts
View file @
a3d875e0
...
...
@@ -2,15 +2,31 @@ import type { DispatcherEvent, OverlayState } from '../shared'
import
{
useReducer
}
from
'react'
import
{
ACTION_DEVTOOLS_POSITION
,
ACTION_BEFORE_REFRESH
,
ACTION_BUILD_ERROR
,
ACTION_BUILD_OK
,
ACTION_BUILDING_INDICATOR_HIDE
,
ACTION_BUILDING_INDICATOR_SHOW
,
ACTION_DEBUG_INFO
,
ACTION_DEV_INDICATOR
,
ACTION_DEVTOOL_UPDATE_ROUTE_STATE
,
ACTION_DEVTOOLS_PANEL_CLOSE
,
ACTION_DEVTOOLS_PANEL_OPEN
,
ACTION_DEVTOOLS_PANEL_TOGGLE
,
ACTION_DEVTOOLS_POSITION
,
ACTION_DEVTOOLS_SCALE
,
ACTION_ERROR_OVERLAY_CLOSE
,
ACTION_ERROR_OVERLAY_OPEN
,
ACTION_ERROR_OVERLAY_TOGGLE
,
ACTION_DEVTOOLS_SCALE
,
ACTION_REFRESH
,
ACTION_RENDERING_INDICATOR_HIDE
,
ACTION_RENDERING_INDICATOR_SHOW
,
ACTION_RESTART_SERVER_BUTTON
,
ACTION_STATIC_INDICATOR
,
ACTION_UNHANDLED_ERROR
,
ACTION_UNHANDLED_REJECTION
,
ACTION_VERSION_INFO
,
INITIAL_OVERLAY_STATE
,
ACTION_DEVTOOLS_PANEL_OPEN
,
}
from
'../shared'
export
const
storybookDefaultOverlayState
:
OverlayState
=
{
...
...
@@ -52,8 +68,25 @@ export function useStorybookOverlayReducer(initialState?: OverlayState) {
case
ACTION_DEVTOOLS_SCALE
:
{
return
{
...
state
,
scale
:
action
.
scale
}
}
default
:
{
case
ACTION_BEFORE_REFRESH
:
case
ACTION_BUILD_ERROR
:
case
ACTION_BUILD_OK
:
case
ACTION_BUILDING_INDICATOR_HIDE
:
case
ACTION_BUILDING_INDICATOR_SHOW
:
case
ACTION_DEBUG_INFO
:
case
ACTION_DEV_INDICATOR
:
case
ACTION_DEVTOOL_UPDATE_ROUTE_STATE
:
case
ACTION_REFRESH
:
case
ACTION_RENDERING_INDICATOR_HIDE
:
case
ACTION_RENDERING_INDICATOR_SHOW
:
case
ACTION_RESTART_SERVER_BUTTON
:
case
ACTION_STATIC_INDICATOR
:
case
ACTION_UNHANDLED_ERROR
:
case
ACTION_UNHANDLED_REJECTION
:
case
ACTION_VERSION_INFO
:
return
state
default
:
{
return
action
satisfies
never
}
}
},
...
...
packages/next/src/server/app-render/app-render-prerender-utils.ts
View file @
a3d875e0
...
...
@@ -31,168 +31,6 @@ export function prerenderAndAbortInSequentialTasks<R>(
}
}
const
PENDING
=
0
const
COMPLETE
=
1
const
INTERRUPTED
=
2
const
ERRORED
=
3
export
class
ServerPrerenderStreamResult
{
private
currentChunks
:
Array
<
Uint8Array
>
private
chunksByPhase
:
Array
<
Array
<
Uint8Array
>>
private
trailingChunks
:
Array
<
Uint8Array
>
private
status
:
0
|
1
|
2
|
3
private
reason
:
null
|
unknown
constructor
(
stream
:
ReadableStream
<
Uint8Array
>
)
{
this
.
status
=
PENDING
this
.
reason
=
null
this
.
trailingChunks
=
[]
this
.
currentChunks
=
[]
this
.
chunksByPhase
=
[
this
.
currentChunks
]
const
reader
=
stream
.
getReader
()
const
progress
=
({
done
,
value
,
}:
ReadableStreamReadResult
<
Uint8Array
>
)
=>
{
if
(
done
)
{
if
(
this
.
status
===
PENDING
)
{
this
.
status
=
COMPLETE
}
return
}
if
(
this
.
status
===
PENDING
||
this
.
status
===
INTERRUPTED
)
{
this
.
currentChunks
.
push
(
value
)
}
else
{
this
.
trailingChunks
.
push
(
value
)
}
reader
.
read
().
then
(
progress
,
error
)
}
const
error
=
(
reason
:
unknown
)
=>
{
this
.
status
=
ERRORED
this
.
reason
=
reason
}
reader
.
read
().
then
(
progress
,
error
)
}
markPhase
()
{
this
.
currentChunks
=
[]
this
.
chunksByPhase
.
push
(
this
.
currentChunks
)
}
markComplete
()
{
if
(
this
.
status
===
PENDING
)
{
this
.
status
=
COMPLETE
}
}
markInterrupted
()
{
this
.
status
=
INTERRUPTED
}
/**
* Returns a stream which only releases chunks when `releasePhase` is called. This stream will never "complete" because
* we rely upon the stream remaining open when prerendering to avoid triggering errors for incomplete chunks in the client.
*
* asPhasedStream is expected to be called once per result however it is safe to call multiple times as long as we have not
* transferred the underlying data. Generally this will only happen when streaming to a response
*/
asPhasedStream
()
{
switch
(
this
.
status
)
{
case
COMPLETE
:
case
INTERRUPTED
:
return
new
PhasedStream
(
this
.
chunksByPhase
)
default
:
throw
new
InvariantError
(
`ServerPrerenderStreamResult cannot be consumed as a stream because it is not yet complete. status:
${
this
.
status
}
`
)
}
}
/**
* Returns a stream which will release all chunks immediately. This stream will "complete" synchronously. It should be used outside
* of render use cases like loading client chunks ahead of SSR or writing the streamed content to disk.
*/
asStream
()
{
switch
(
this
.
status
)
{
case
COMPLETE
:
case
INTERRUPTED
:
const
chunksByPhase
=
this
.
chunksByPhase
const
trailingChunks
=
this
.
trailingChunks
return
new
ReadableStream
({
start
(
controller
)
{
for
(
let
i
=
0
;
i
<
chunksByPhase
.
length
;
i
++
)
{
const
chunks
=
chunksByPhase
[
i
]
for
(
let
j
=
0
;
j
<
chunks
.
length
;
j
++
)
{
controller
.
enqueue
(
chunks
[
j
])
}
}
for
(
let
i
=
0
;
i
<
trailingChunks
.
length
;
i
++
)
{
controller
.
enqueue
(
trailingChunks
[
i
])
}
controller
.
close
()
},
})
default
:
throw
new
InvariantError
(
`ServerPrerenderStreamResult cannot be consumed as a stream because it is not yet complete. status:
${
this
.
status
}
`
)
}
}
}
class
PhasedStream
<
T
>
extends
ReadableStream
<
T
>
{
private
nextPhase
:
number
private
chunksByPhase
:
Array
<
Array
<
T
>>
private
destination
:
ReadableStreamDefaultController
<
T
>
constructor
(
chunksByPhase
:
Array
<
Array
<
T
>>
)
{
if
(
chunksByPhase
.
length
===
0
)
{
throw
new
InvariantError
(
'PhasedStream expected at least one phase but none were found.'
)
}
let
destination
:
ReadableStreamDefaultController
<
T
>
super
({
start
(
controller
)
{
destination
=
controller
},
})
// the start function above is called synchronously during construction so we will always have a destination
// We wait to assign it until after the super call because we cannot access `this` before calling super
this
.
destination
=
destination
!
this
.
nextPhase
=
0
this
.
chunksByPhase
=
chunksByPhase
this
.
releasePhase
()
}
releasePhase
()
{
if
(
this
.
nextPhase
<
this
.
chunksByPhase
.
length
)
{
const
chunks
=
this
.
chunksByPhase
[
this
.
nextPhase
++
]
for
(
let
i
=
0
;
i
<
chunks
.
length
;
i
++
)
{
this
.
destination
.
enqueue
(
chunks
[
i
])
}
}
else
{
throw
new
InvariantError
(
'PhasedStream expected more phases to release but none were found.'
)
}
}
assertExhausted
()
{
if
(
this
.
nextPhase
<
this
.
chunksByPhase
.
length
)
{
throw
new
InvariantError
(
'PhasedStream expected no more phases to release but some were found.'
)
}
}
}
// React's RSC prerender function will emit an incomplete flight stream when using `prerender`. If the connection
// closes then whatever hanging chunks exist will be errored. This is because prerender (an experimental feature)
// has not yet implemented a concept of resume. For now we will simulate a paused connection by wrapping the stream
...
...
packages/next/src/server/app-render/app-render.tsx
View file @
a3d875e0
...
...
@@ -153,10 +153,7 @@ import { createMutableActionQueue } from '../../client/components/app-router-ins
import
{
getRevalidateReason
}
from
'../instrumentation/utils'
import
{
PAGE_SEGMENT_KEY
}
from
'../../shared/lib/segment'
import
type
{
FallbackRouteParams
}
from
'../request/fallback-params'
import
{
ServerPrerenderStreamResult
,
processPrelude
,
}
from
'./app-render-prerender-utils'
import
{
processPrelude
}
from
'./app-render-prerender-utils'
import
{
type
ReactServerPrerenderResult
,
ReactServerResult
,
...
...
@@ -2889,10 +2886,7 @@ async function prerenderToStream(
onHTMLRenderSSRError
)
let
reactServerPrerenderResult
:
|
null
|
ReactServerPrerenderResult
|
ServerPrerenderStreamResult
=
null
let
reactServerPrerenderResult
:
null
|
ReactServerPrerenderResult
=
null
const
setMetadataHeader
=
(
name
:
string
)
=>
{
metadata
.
headers
??
=
{}
metadata
.
headers
[
name
]
=
res
.
getHeader
(
name
)
...
...
@@ -3945,10 +3939,7 @@ async function prerenderToStream(
// This is intentionally using the readable datastream from the main
// render rather than the flight data from the error page render
const
flightStream
=
reactServerPrerenderResult
instanceof
ServerPrerenderStreamResult
?
reactServerPrerenderResult
.
asStream
()
:
reactServerPrerenderResult
.
consumeAsStream
()
const
flightStream
=
reactServerPrerenderResult
.
consumeAsStream
()
return
{
// Returning the error that was thrown so it can be used to handle
...
...
packages/next/src/server/app-render/csrf-protection.ts
View file @
a3d875e0
...
...
@@ -51,6 +51,7 @@ function matchWildcardDomain(domain: string, pattern: string) {
// recursive wildcard matches anything so we terminate here if the domain part is non empty
return
domainPart
!==
undefined
}
case
undefined
:
default
:
{
if
(
domainPart
!==
patternPart
)
{
return
false
...
...
packages/next/src/server/dev/browser-logs/receive-logs.ts
View file @
a3d875e0
...
...
@@ -440,11 +440,25 @@ export async function handleLog(
await
handleDir
(
entry
,
browserPrefix
,
ctx
,
distDir
)
break
}
// xml log thing maybe needs an impl
// [browser] undefined (app/page.tsx:8:11) console.group
// check console assert
default
:
{
case
'dirxml'
:
{
// xml log thing maybe needs an impl
// fallthrough
}
case
'group'
:
case
'groupCollapsed'
:
case
'groupEnd'
:
{
// [browser] undefined (app/page.tsx:8:11) console.group
// fallthrough
}
case
'assert'
:
{
// check console assert
// fallthrough
}
case
'log'
:
case
'info'
:
case
'debug'
:
case
'error'
:
case
'warn'
:
{
await
handleDefaultConsole
(
entry
,
browserPrefix
,
...
...
@@ -452,6 +466,10 @@ export async function handleLog(
distDir
,
config
)
break
}
default
:
{
entry
satisfies
never
}
}
break
...
...
packages/next/src/server/dev/hot-reloader-types.ts
View file @
a3d875e0
...
...
@@ -119,11 +119,6 @@ export interface AppIsrManifestAction {
data
:
Record
<
string
,
boolean
>
}
export
interface
DevIndicatorAction
{
action
:
HMR_ACTIONS_SENT_TO_BROWSER
.
DEV_INDICATOR
devIndicator
:
DevIndicatorServerState
}
export
type
HMR_ACTION_TYPES
=
|
TurbopackMessageAction
|
TurbopackConnectedAction
...
...
@@ -140,7 +135,6 @@ export type HMR_ACTION_TYPES =
|
DevPagesManifestUpdateAction
|
ServerErrorAction
|
AppIsrManifestAction
|
DevIndicatorAction
export
type
TurbopackMsgToBrowser
=
|
{
type
:
HMR_ACTIONS_SENT_TO_BROWSER
.
TURBOPACK_MESSAGE
;
data
:
any
}
...
...
packages/next/src/server/dev/log-requests.ts
View file @
a3d875e0
...
...
@@ -171,7 +171,10 @@ function formatCacheStatus(cacheStatus: FetchMetric['cacheStatus']): string {
return
green
(
'(HMR cache)'
)
case
'hit'
:
return
green
(
'(cache hit)'
)
default
:
case
'miss'
:
case
'skip'
:
return
yellow
(
`(cache
${
cacheStatus
}
)`
)
default
:
return
cacheStatus
satisfies
never
}
}
packages/next/src/server/dev/turbopack-utils.ts
View file @
a3d875e0
...
...
@@ -621,9 +621,11 @@ export async function handleEntrypoints({
currentEntrypoints
.
app
.
set
(
route
.
originalName
,
route
)
break
}
default
:
case
'conflict'
:
Log
.
info
(
`skipping
${
pathname
}
(
${
route
.
type
}
)`
)
break
default
:
route
satisfies
never
}
}
...
...
packages/next/src/server/lib/patch-fetch.ts
View file @
a3d875e0
...
...
@@ -609,11 +609,17 @@ export function createPatchedFetcher(
}
break
}
case
'default-cache'
:
case
'default-no-store'
:
case
'auto'
:
case
undefined
:
// sometimes we won't match the above cases. the reason we don't move
// everything to this switch is the use of autoNoCache which is not a fetchCacheMode
// I suspect this could be unified with fetchCacheMode however in which case we could
// simplify the switch case and ensure we have an exhaustive switch handling all modes
break
default
:
// sometimes we won't match the above cases. the reason we don't move
// everything to this switch is the use of autoNoCache which is not a fetchCacheMode
// I suspect this could be unified with fetchCacheMode however in which case we could
// simplify the switch case and ensure we have an exhaustive switch handling all modes
pageFetchCacheMode
satisfies
never
}
if
(
typeof
finalRevalidate
===
'undefined'
)
{
...
...
packages/next/src/server/lib/router-utils/filesystem.ts
View file @
a3d875e0
...
...
@@ -611,9 +611,15 @@ export async function setupFsCheck(opts: {
itemsRoot
=
publicFolderPath
break
}
default
:
{
case
'appFile'
:
case
'pageFile'
:
case
'nextImage'
:
case
'devVirtualFsItem'
:
{
break
}
default
:
{
;(
type
)
satisfies
never
}
}
if
(
itemsRoot
&&
curItemPath
)
{
...
...
packages/next/src/server/node-environment-extensions/console-dev.tsx
View file @
a3d875e0
...
...
@@ -97,6 +97,8 @@ function dimConsoleCall(
switch
(
methodName
)
{
case
'dir'
:
case
'dirxml'
:
case
'group'
:
case
'groupCollapsed'
:
case
'groupEnd'
:
case
'table'
:
{
// These methods cannot be colorized because they don't take a formatting string.
...
...
@@ -109,10 +111,17 @@ function dimConsoleCall(
...
formatConsoleArguments
(
args
[
1
],
...
args
.
slice
(
2
))
)
}
default
:
case
'error'
:
case
'debug'
:
case
'info'
:
case
'log'
:
case
'trace'
:
case
'warn'
:
return
[
ANSI_STYLE_DIMMING_TEMPLATE
].
concat
(
...
formatConsoleArguments
(
args
[
0
],
...
args
.
slice
(
1
))
)
default
:
return
methodName
satisfies
never
}
}
...
...
packages/next/src/server/response-cache/utils.ts
View file @
a3d875e0
...
...
@@ -82,7 +82,10 @@ export function routeKindToIncrementalCacheKind(
return
IncrementalCacheKind
.
IMAGE
case
RouteKind
.
APP_ROUTE
:
return
IncrementalCacheKind
.
APP_ROUTE
default
:
case
RouteKind
.
PAGES_API
:
// Pages Router API routes are not cached in the incremental cache.
throw
new
Error
(
`Unexpected route kind
${
routeKind
}
`
)
default
:
return
routeKind
satisfies
never
}
}
packages/next/src/server/route-modules/app-route/module.ts
View file @
a3d875e0
...
...
@@ -754,9 +754,14 @@ export class AppRouteRouteModule extends RouteModule<
if
(
workStore
.
isStaticGeneration
)
request
=
new
Proxy
(
req
,
requireStaticRequestHandlers
)
break
default
:
// We proxy `NextRequest` to track dynamic access, and potentially bail out of static generation
case
undefined
:
case
'auto'
:
// We proxy `NextRequest` to track dynamic access, and
// potentially bail out of static generation.
request
=
proxyNextRequest
(
req
,
workStore
)
break
default
:
this
.
dynamic
satisfies
never
}
// TODO: propagate this pathname from route matcher
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment