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
9d1572d7
Commit
9d1572d7
authored
Mar 28, 2026
by
Jude Gao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DevServer] Add global lockfile for server discovery
parent
7bce97d6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
setup-dev-bundler.ts
...ges/next/src/server/lib/router-utils/setup-dev-bundler.ts
+26
-0
No files found.
packages/next/src/server/lib/router-utils/setup-dev-bundler.ts
View file @
9d1572d7
...
...
@@ -10,6 +10,7 @@ import type { NextJsHotReloaderInterface } from '../../dev/hot-reloader-types'
import
{
createDefineEnv
}
from
'../../../build/swc'
import
{
installBindings
}
from
'../../../build/swc/install-bindings'
import
fs
from
'fs'
import
os
from
'os'
import
path
from
'path'
import
qs
from
'querystring'
import
Watchpack
from
'next/dist/compiled/watchpack'
...
...
@@ -218,6 +219,31 @@ async function startWatcher(
)
}
// Create a global lockfile at ~/.next/dev/<port>/lock so external tools can
// enumerate all running dev servers by scanning ~/.next/dev/*/lock.
const
globalLockDir
=
path
.
join
(
os
.
homedir
(),
'.next'
,
'dev'
,
String
(
opts
.
port
)
)
fs
.
mkdirSync
(
globalLockDir
,
{
recursive
:
true
})
const
globalServerInfo
:
DevServerInfo
=
{
pid
:
process
.
pid
,
port
:
opts
.
port
,
hostname
:
'localhost'
,
appUrl
:
`http://localhost:
${
opts
.
port
}
`
,
startedAt
:
Date
.
now
(),
}
const
globalLockfile
=
Lockfile
.
tryAcquire
(
path
.
join
(
globalLockDir
,
'lock'
),
true
,
JSON
.
stringify
(
globalServerInfo
)
)
opts
.
onDevServerCleanup
?.(
async
()
=>
{
await
globalLockfile
?.
unlock
()
})
const
validFileMatcher
=
createValidFileMatcher
(
nextConfig
.
pageExtensions
,
appDir
...
...
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