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
b56342b3
Commit
b56342b3
authored
Aug 12, 2025
by
Benjamin Woodruff
Committed by
Benjamin Woodruff
Sep 22, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
next-dev: Emit `next.config.js` warnings from child process upon restart
parent
b8531670
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
66 deletions
+55
-66
next-dev.ts
packages/next/src/cli/next-dev.ts
+1
-1
router-server.ts
packages/next/src/server/lib/router-server.ts
+4
-17
start-server.ts
packages/next/src/server/lib/start-server.ts
+35
-43
next.ts
packages/next/src/server/next.ts
+15
-5
No files found.
packages/next/src/cli/next-dev.ts
View file @
b56342b3
...
...
@@ -346,7 +346,7 @@ const nextDev = async (
})
}
return
startServer
({
...
startServerOptions
,
port
})
return
startServer
({
...
startServerOptions
,
port
,
isRestart
:
true
})
}
// Call handler (e.g. upload telemetry). Don't try to send a signal to
// the child, as it has already exited.
...
...
packages/next/src/server/lib/router-server.ts
View file @
b56342b3
...
...
@@ -9,7 +9,6 @@ import '../require-hook'
import
url
from
'url'
import
path
from
'path'
import
loadConfig
from
'../config'
import
{
serveStatic
}
from
'../serve-static'
import
setupDebug
from
'next/dist/compiled/debug'
import
*
as
Log
from
'../../build/output/log'
...
...
@@ -27,11 +26,7 @@ import { signalFromNodeResponse } from '../web/spec-extension/adapters/next-requ
import
{
isPostpone
}
from
'./router-utils/is-postpone'
import
{
parseUrl
as
parseUrlUtil
}
from
'../../shared/lib/router/utils/parse-url'
import
{
PHASE_PRODUCTION_SERVER
,
PHASE_DEVELOPMENT_SERVER
,
UNDERSCORE_NOT_FOUND_ROUTE
,
}
from
'../../shared/lib/constants'
import
{
UNDERSCORE_NOT_FOUND_ROUTE
}
from
'../../shared/lib/constants'
import
{
RedirectStatusCode
}
from
'../../client/components/redirect-status-code'
import
{
DevBundlerService
}
from
'./dev-bundler-service'
import
{
type
Span
,
trace
}
from
'../../trace'
...
...
@@ -59,6 +54,7 @@ import {
handleChromeDevtoolsWorkspaceRequest
,
isChromeDevtoolsWorkspaceUrl
,
}
from
'./chrome-devtools-workspace'
import
type
{
NextConfigComplete
}
from
'../config-shared'
const
debug
=
setupDebug
(
'next:router-server:main'
)
const
isNextFont
=
(
pathname
:
string
|
null
)
=>
...
...
@@ -80,6 +76,7 @@ const requestHandlers: Record<string, WorkerRequestHandler> = {}
export
async
function
initialize
(
opts
:
{
dir
:
string
config
:
NextConfigComplete
port
:
number
dev
:
boolean
onDevServerCleanup
:
((
listener
:
()
=>
Promise
<
void
>
)
=>
void
)
|
undefined
...
...
@@ -92,19 +89,9 @@ export async function initialize(opts: {
startServerSpan
?:
Span
quiet
?:
boolean
}):
Promise
<
ServerInitResult
>
{
if
(
!
process
.
env
.
NODE_ENV
)
{
// @ts-ignore not readonly
process
.
env
.
NODE_ENV
=
opts
.
dev
?
'development'
:
'production'
}
const
config
=
await
loadConfig
(
opts
.
dev
?
PHASE_DEVELOPMENT_SERVER
:
PHASE_PRODUCTION_SERVER
,
opts
.
dir
,
{
silent
:
false
}
)
const
{
config
}
=
opts
let
compress
:
ReturnType
<
typeof
setupCompression
>
|
undefined
if
(
config
?.
compress
!==
false
)
{
compress
=
setupCompression
()
}
...
...
packages/next/src/server/lib/start-server.ts
View file @
b56342b3
...
...
@@ -28,8 +28,12 @@ import {
getNodeDebugType
,
}
from
'./utils'
import
{
formatHostname
}
from
'./format-hostname'
import
{
initialize
}
from
'./router-server'
import
{
CONFIG_FILES
}
from
'../../shared/lib/constants'
import
{
initialize
as
initializeRouterServer
}
from
'./router-server'
import
{
CONFIG_FILES
,
PHASE_DEVELOPMENT_SERVER
,
PHASE_PRODUCTION_SERVER
,
}
from
'../../shared/lib/constants'
import
{
getStartServerInfo
,
logStartInfo
}
from
'./app-info-log'
import
{
validateTurboNextConfig
}
from
'../../lib/turbopack-warning'
import
{
type
Span
,
trace
,
flushAllTraces
}
from
'../../trace'
...
...
@@ -37,6 +41,7 @@ import { isIPv6 } from './is-ipv6'
import
{
AsyncCallbackSet
}
from
'./async-callback-set'
import
type
{
NextServer
}
from
'../next'
import
type
{
ConfiguredExperimentalFeature
}
from
'../config'
import
loadConfig
from
'../config'
const
debug
=
setupDebug
(
'next:start-server'
)
let
startServerSpan
:
Span
|
undefined
...
...
@@ -127,44 +132,7 @@ export interface StartServerOptions {
keepAliveTimeout
?:
number
// this is dev-server only
selfSignedCertificate
?:
SelfSignedCertificate
}
export
async
function
getRequestHandlers
({
dir
,
port
,
isDev
,
onDevServerCleanup
,
server
,
hostname
,
minimalMode
,
keepAliveTimeout
,
experimentalHttpsServer
,
quiet
,
}:
{
dir
:
string
port
:
number
isDev
:
boolean
onDevServerCleanup
:
((
listener
:
()
=>
Promise
<
void
>
)
=>
void
)
|
undefined
server
?:
import
(
'http'
).
Server
hostname
?:
string
minimalMode
?:
boolean
keepAliveTimeout
?:
number
experimentalHttpsServer
?:
boolean
quiet
?:
boolean
}):
ReturnType
<
typeof
initialize
>
{
return
initialize
({
dir
,
port
,
hostname
,
onDevServerCleanup
,
dev
:
isDev
,
minimalMode
,
server
,
keepAliveTimeout
,
experimentalHttpsServer
,
startServerSpan
,
quiet
,
})
isRestart
?:
boolean
}
export
async
function
startServer
(
...
...
@@ -178,6 +146,7 @@ export async function startServer(
allowRetry
,
keepAliveTimeout
,
selfSignedCertificate
,
isRestart
,
}
=
serverOptions
let
{
port
}
=
serverOptions
...
...
@@ -364,7 +333,29 @@ export async function startServer(
process
.
env
.
__NEXT_EXPERIMENTAL_HTTPS
=
'1'
}
// Only load env and config in dev to for logging purposes
// @ts-ignore not readonly
process
.
env
.
NODE_ENV
||=
isDev
?
'development'
:
'production'
// this needs to happen before `getStartServerInfo`, which also calls `loadConfig`, so that
// the `silent` flag applies.
const
config
=
await
loadConfig
(
isDev
?
PHASE_DEVELOPMENT_SERVER
:
PHASE_PRODUCTION_SERVER
,
dir
,
{
// Normally, the parent process is responsible for emitting any configuration-related
// warnings.
//
// If this is a restart, the parent process cannot read the config again because there's
// no way to invalidate the node ESM import cache.
//
// Instead, we should load the config with `silent: false` so that we log any new
// warnings. This may also cause us to re-log deprecation warnings that were previously
// logged prior to the restart -- there's no way for us to re-use the `warnOnce` cache.
silent
:
!
isRestart
,
}
)
// Only load env and and experimental feature info in dev to for logging purposes
let
envInfo
:
string
[]
|
undefined
let
experimentalFeatures
:
ConfiguredExperimentalFeature
[]
|
undefined
try
{
...
...
@@ -428,10 +419,11 @@ export async function startServer(
process
.
on
(
'SIGTERM'
,
cleanup
)
}
const
initResult
=
await
getRequestHandlers
({
const
initResult
=
await
initializeRouterServer
({
dir
,
config
,
port
,
isDev
,
dev
:
isDev
,
onDevServerCleanup
:
cleanupListeners
?
cleanupListeners
.
add
.
bind
(
cleanupListeners
)
:
undefined
,
...
...
packages/next/src/server/next.ts
View file @
b56342b3
...
...
@@ -373,8 +373,8 @@ class NextCustomServer implements NextWrapperServer {
}
async
prepare
()
{
const
{
getRequestHandlers
}
=
require
(
'./lib/
start-server'
)
as
typeof
import
(
'./lib/start
-server'
)
const
{
initialize
}
=
require
(
'./lib/
router-server'
)
as
typeof
import
(
'./lib/router
-server'
)
let
onDevServerCleanup
:
AsyncCallbackSet
[
'add'
]
|
undefined
if
(
this
.
options
.
dev
)
{
...
...
@@ -382,16 +382,26 @@ class NextCustomServer implements NextWrapperServer {
onDevServerCleanup
=
this
.
cleanupListeners
.
add
.
bind
(
this
.
cleanupListeners
)
}
const
initResult
=
await
getRequestHandlers
({
let
dev
=
!!
this
.
options
.
dev
let
dir
=
this
.
options
.
dir
!
// @ts-ignore not readonly
process
.
env
.
NODE_ENV
||=
dev
?
'development'
:
'production'
const
config
=
await
loadConfig
(
dev
?
PHASE_DEVELOPMENT_SERVER
:
PHASE_PRODUCTION_SERVER
,
dir
)
this
.
init
=
await
initialize
({
dir
:
this
.
options
.
dir
!
,
config
,
port
:
this
.
options
.
port
||
3000
,
isD
ev
:
!!
this
.
options
.
dev
,
d
ev
:
!!
this
.
options
.
dev
,
onDevServerCleanup
,
hostname
:
this
.
options
.
hostname
||
'localhost'
,
minimalMode
:
this
.
options
.
minimalMode
,
quiet
:
this
.
options
.
quiet
,
})
this
.
init
=
initResult
}
private
setupWebSocketHandler
(
...
...
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