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
ffbd2953
Commit
ffbd2953
authored
Nov 18, 2025
by
Niklas Mischkulnig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test
parent
b3b97bc4
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
131 additions
and
0 deletions
+131
-0
Component.tsx
test/development/app-dir/hmr-iframe/app/page1/Component.tsx
+5
-0
page.tsx
test/development/app-dir/hmr-iframe/app/page1/page.tsx
+18
-0
subscribeToHMR.ts
...evelopment/app-dir/hmr-iframe/app/page1/subscribeToHMR.ts
+55
-0
page.tsx
test/development/app-dir/hmr-iframe/app/page2/page.tsx
+13
-0
hmr-iframe.test.ts
test/development/app-dir/hmr-iframe/hmr-iframe.test.ts
+35
-0
next.config.js
test/development/app-dir/hmr-iframe/next.config.js
+5
-0
No files found.
test/development/app-dir/hmr-iframe/app/page1/Component.tsx
0 → 100644
View file @
ffbd2953
'use client'
export
function
Component
()
{
return
<
p
>
Component
</
p
>
}
test/development/app-dir/hmr-iframe/app/page1/page.tsx
0 → 100644
View file @
ffbd2953
import
{
subscribeToHMR
}
from
'./subscribeToHMR'
import
{
Component
}
from
'./Component'
const
RootPage
=
async
({
Component
}:
any
)
=>
{
await
subscribeToHMR
()
return
(
<
html
>
<
body
>
<
iframe
src=
"/page2"
/>
</
body
>
</
html
>
)
}
export
default
function
Page
()
{
return
<
RootPage
Component=
{
Component
}
/>
}
test/development/app-dir/hmr-iframe/app/page1/subscribeToHMR.ts
0 → 100644
View file @
ffbd2953
if
(
!
global
.
_payload
)
{
global
.
_payload
=
{
payload
:
null
,
reload
:
false
,
ws
:
null
,
}
}
export
const
subscribeToHMR
=
async
()
=>
{
let
cached
=
global
.
_payload
if
(
cached
.
payload
)
{
if
(
cached
.
reload
===
true
)
{
let
resolve
:
any
cached
.
reload
=
new
Promise
((
res
)
=>
(
resolve
=
res
))
await
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
200
))
resolve
()
}
if
(
cached
.
reload
instanceof
Promise
)
{
await
cached
.
reload
}
return
cached
.
payload
}
cached
.
payload
=
{}
const
port
=
process
.
env
.
PORT
||
'3000'
const
hasHTTPS
=
process
.
env
.
USE_HTTPS
===
'true'
||
process
.
argv
.
includes
(
'--experimental-https'
)
const
protocol
=
hasHTTPS
?
'wss'
:
'ws'
const
path
=
'/_next/webpack-hmr'
// The __NEXT_ASSET_PREFIX env variable is set for both assetPrefix and basePath (tested in Next.js 15.1.6)
const
prefix
=
process
.
env
.
__NEXT_ASSET_PREFIX
??
''
cached
.
ws
=
new
WebSocket
(
process
.
env
.
PAYLOAD_HMR_URL_OVERRIDE
??
`
${
protocol
}
://localhost:
${
port
}${
prefix
}${
path
}
`
)
cached
.
ws
.
onmessage
=
(
event
:
any
)
=>
{
if
(
typeof
event
.
data
===
'string'
)
{
const
data
=
JSON
.
parse
(
event
.
data
)
if
(
// On Next.js 15, we need to check for data.action. On Next.js 16, we need to check for data.type.
data
.
type
===
'serverComponentChanges'
||
data
.
action
===
'serverComponentChanges'
)
{
cached
.
reload
=
true
}
}
}
}
test/development/app-dir/hmr-iframe/app/page2/page.tsx
0 → 100644
View file @
ffbd2953
import
{
subscribeToHMR
}
from
'../page1/subscribeToHMR'
export
default
async
function
Page
()
{
await
subscribeToHMR
()
return
(
<
html
>
<
body
>
<
p
>
content
</
p
>
</
body
>
</
html
>
)
}
test/development/app-dir/hmr-iframe/hmr-iframe.test.ts
0 → 100644
View file @
ffbd2953
import
{
nextTestSetup
}
from
'e2e-utils'
import
{
waitForNoRedbox
}
from
'next-test-utils'
describe
(
'hmr-iframe'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
})
it
(
'should do HMR when rendering two server component changes at the same time'
,
async
()
=>
{
let
browser
=
await
next
.
browser
(
'/page1'
)
expect
(
await
(
await
(
await
browser
.
elementByCss
(
'iframe'
)).
contentFrame
())
.
locator
(
'p'
)
.
innerText
()
).
toEqual
(
'content'
)
await
next
.
patchFile
(
'app/page2/page.tsx'
,
(
content
)
=>
content
.
replace
(
'content'
,
'content-new'
)
)
await
waitForNoRedbox
(
browser
)
expect
(
await
(
await
(
await
browser
.
elementByCss
(
'iframe'
)).
contentFrame
())
.
locator
(
'p'
)
.
innerText
()
).
toEqual
(
'content-new'
)
expect
(
next
.
cliOutput
).
not
.
toContain
(
'Error'
)
expect
(
next
.
cliOutput
).
not
.
toContain
(
'Could not find the module'
)
await
next
.
stop
()
await
next
.
clean
()
})
})
test/development/app-dir/hmr-iframe/next.config.js
0 → 100644
View file @
ffbd2953
module
.
exports
=
{
experimental
:
{
appDir
:
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