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
f85e550b
Commit
f85e550b
authored
Mar 28, 2026
by
Jude Gao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add e2e test for global lockfile server discovery
parent
9d1572d7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
lockfile.test.ts
test/development/lockfile/lockfile.test.ts
+39
-0
No files found.
test/development/lockfile/lockfile.test.ts
View file @
f85e550b
import
{
nextTestSetup
}
from
'e2e-utils'
import
execa
from
'execa'
import
fs
from
'fs'
import
os
from
'os'
import
path
from
'path'
import
stripAnsi
from
'strip-ansi'
...
...
@@ -9,6 +10,12 @@ describe('lockfile', () => {
files
:
__dirname
,
})
afterAll
(()
=>
{
// Clean up global lockfile created during test
const
globalLockDir
=
path
.
join
(
os
.
homedir
(),
'.next'
,
'dev'
,
next
.
appPort
)
fs
.
rmSync
(
globalLockDir
,
{
recursive
:
true
,
force
:
true
})
})
it
(
'only allows a single instance of `next dev` to run at a time'
,
async
()
=>
{
const
browser
=
await
next
.
browser
(
'/'
)
expect
(
await
browser
.
elementByCss
(
'p'
).
text
()).
toBe
(
'Page'
)
...
...
@@ -67,4 +74,36 @@ describe('lockfile', () => {
await
browser
.
refresh
()
expect
(
await
browser
.
elementByCss
(
'p'
).
text
()).
toBe
(
'Page'
)
})
it
(
'creates a global lockfile at ~/.next/dev/<port>/lock with flock held'
,
async
()
=>
{
const
globalLockfilePath
=
path
.
join
(
os
.
homedir
(),
'.next'
,
'dev'
,
next
.
appPort
,
'lock'
)
expect
(
fs
.
existsSync
(
globalLockfilePath
)).
toBe
(
true
)
// Verify lockfile content has correct server info
const
serverInfo
=
JSON
.
parse
(
fs
.
readFileSync
(
globalLockfilePath
,
'utf-8'
))
expect
(
serverInfo
).
toMatchObject
({
pid
:
expect
.
any
(
Number
),
port
:
Number
(
next
.
appPort
),
hostname
:
'localhost'
,
appUrl
:
expect
.
stringContaining
(
next
.
appPort
),
startedAt
:
expect
.
any
(
Number
),
})
// Verify the process from the lockfile is actually alive
const
isAlive
=
(()
=>
{
try
{
process
.
kill
(
serverInfo
.
pid
,
0
)
return
true
}
catch
{
return
false
}
})()
expect
(
isAlive
).
toBe
(
true
)
})
})
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