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
d1226874
Commit
d1226874
authored
Dec 10, 2025
by
Jiachi Liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor into devtool
parent
ae18e3db
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
765 additions
and
321 deletions
+765
-321
suspense-profiler.css
...ols/dev-overlay/components/overview/suspense-profiler.css
+275
-0
suspense-profiler.tsx
...ols/dev-overlay/components/overview/suspense-profiler.tsx
+421
-0
context.tsx
packages/next/src/next-devtools/dev-overlay/menu/context.tsx
+1
-0
panel-router.tsx
.../next/src/next-devtools/dev-overlay/menu/panel-router.tsx
+41
-0
make-get-server-inserted-html.tsx
...t/src/server/app-render/make-get-server-inserted-html.tsx
+11
-9
suspense-boundary-injector.tsx
...next/src/server/app-render/suspense-boundary-injector.tsx
+16
-312
No files found.
packages/next/src/next-devtools/dev-overlay/components/overview/suspense-profiler.css
0 → 100644
View file @
d1226874
.suspense-profiler
{
display
:
flex
;
flex-direction
:
column
;
height
:
100%
;
font-size
:
var
(
--size-14
);
}
.suspense-profiler-header
{
display
:
flex
;
align-items
:
center
;
padding
:
14px
16px
;
background-color
:
var
(
--color-background-200
);
gap
:
12px
;
border-bottom
:
1px
solid
var
(
--color-gray-400
);
}
.suspense-profiler-header-title
{
font-size
:
var
(
--size-14
);
font-weight
:
500
;
color
:
var
(
--color-gray-1000
);
line-height
:
20px
;
}
.suspense-profiler-stats
{
display
:
flex
;
gap
:
12px
;
margin-left
:
auto
;
}
.suspense-profiler-stat
{
display
:
inline-flex
;
align-items
:
center
;
gap
:
4px
;
font-size
:
var
(
--size-12
);
color
:
var
(
--color-gray-800
);
}
.suspense-profiler-stat-value
{
font-weight
:
600
;
color
:
var
(
--color-gray-1000
);
}
.suspense-profiler-content
{
flex
:
1
;
overflow
:
auto
;
padding
:
8px
0
;
}
.suspense-profiler-empty
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
height
:
100%
;
color
:
var
(
--color-gray-800
);
font-size
:
var
(
--size-14
);
}
.suspense-profiler-node-row
{
display
:
flex
;
align-items
:
center
;
padding
:
8px
12px
;
gap
:
8px
;
cursor
:
pointer
;
transition
:
background-color
0.15s
ease
;
}
.suspense-profiler-node-row
:hover
{
background-color
:
var
(
--color-background-200
);
}
.suspense-profiler-toggle
{
width
:
12px
;
color
:
var
(
--color-gray-700
);
font-size
:
10px
;
flex-shrink
:
0
;
}
.suspense-profiler-toggle-placeholder
{
width
:
12px
;
flex-shrink
:
0
;
}
.suspense-profiler-name
{
font-weight
:
500
;
color
:
var
(
--color-gray-1000
);
}
.suspense-profiler-badge
{
display
:
inline-flex
;
align-items
:
center
;
padding
:
2px
8px
;
border-radius
:
12px
;
font-size
:
var
(
--size-11
);
font-weight
:
500
;
}
.suspense-profiler-badge--suspense
{
background-color
:
var
(
--color-blue-300
);
color
:
var
(
--color-blue-900
);
}
.suspense-profiler-status
{
margin-left
:
auto
;
font-size
:
var
(
--size-12
);
color
:
var
(
--color-gray-700
);
}
.suspense-profiler-status--ok
{
color
:
var
(
--color-green-900
);
}
.suspense-profiler-insights-btn
{
margin-left
:
auto
;
padding
:
4px
10px
;
background
:
var
(
--color-background-100
);
border
:
1px
solid
var
(
--color-gray-400
);
border-radius
:
4px
;
font-size
:
var
(
--size-12
);
color
:
var
(
--color-gray-1000
);
cursor
:
pointer
;
transition
:
background-color
0.15s
ease
;
}
.suspense-profiler-insights-btn
:hover
{
background
:
var
(
--color-gray-200
);
}
/* Dynamic API row */
.suspense-profiler-api-row
{
display
:
flex
;
align-items
:
center
;
padding
:
6px
12px
;
gap
:
8px
;
}
.suspense-profiler-api-code
{
font-family
:
var
(
--font-mono
);
font-size
:
var
(
--size-12
);
background
:
var
(
--color-gray-200
);
padding
:
2px
6px
;
border-radius
:
4px
;
color
:
var
(
--color-gray-1000
);
}
.suspense-profiler-collapse-btn
{
width
:
16px
;
height
:
16px
;
padding
:
0
;
background
:
var
(
--color-gray-200
);
border
:
none
;
border-radius
:
4px
;
font-size
:
var
(
--size-12
);
color
:
var
(
--color-gray-700
);
cursor
:
pointer
;
display
:
inline-flex
;
align-items
:
center
;
justify-content
:
center
;
flex-shrink
:
0
;
}
.suspense-profiler-collapse-btn
:hover
{
background
:
var
(
--color-gray-300
);
}
.suspense-profiler-collapse-placeholder
{
width
:
16px
;
flex-shrink
:
0
;
}
.suspense-profiler-layers-badge
{
display
:
inline-flex
;
align-items
:
center
;
justify-content
:
center
;
min-width
:
16px
;
height
:
16px
;
padding
:
0
4px
;
margin-left
:
6px
;
font-size
:
var
(
--size-11
);
font-weight
:
600
;
color
:
var
(
--color-amber-900
);
background
:
var
(
--color-amber-200
);
border-radius
:
8px
;
}
/* Component trace */
.suspense-profiler-trace
{
padding
:
4px
12px
8px
;
}
.suspense-profiler-trace-item
{
font-size
:
var
(
--size-12
);
color
:
var
(
--color-gray-700
);
padding
:
2px
0
;
font-family
:
var
(
--font-mono
);
}
.suspense-profiler-trace-item
::before
{
content
:
'└ '
;
color
:
var
(
--color-gray-500
);
}
/* Modal */
.suspense-profiler-modal-overlay
{
position
:
fixed
;
inset
:
0
;
background
:
rgba
(
0
,
0
,
0
,
0.5
);
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
z-index
:
100000
;
}
.suspense-profiler-modal
{
background
:
var
(
--color-background-100
);
padding
:
16px
;
border-radius
:
8px
;
max-width
:
500px
;
max-height
:
80vh
;
overflow
:
auto
;
font-size
:
var
(
--size-13
);
white-space
:
pre-wrap
;
color
:
var
(
--color-gray-1000
);
border
:
1px
solid
var
(
--color-gray-400
);
}
.suspense-profiler-modal-header
{
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
margin-bottom
:
12px
;
padding-bottom
:
12px
;
border-bottom
:
1px
solid
var
(
--color-gray-400
);
}
.suspense-profiler-modal-title
{
font-weight
:
600
;
font-size
:
var
(
--size-14
);
}
.suspense-profiler-modal-close
{
background
:
none
;
border
:
none
;
font-size
:
18px
;
cursor
:
pointer
;
color
:
var
(
--color-gray-700
);
padding
:
0
4px
;
line-height
:
1
;
}
.suspense-profiler-modal-close
:hover
{
color
:
var
(
--color-gray-1000
);
}
.suspense-profiler-modal-content
{
font-family
:
var
(
--font-mono
);
font-size
:
var
(
--size-12
);
line-height
:
1.5
;
}
.suspense-profiler-modal-copy
{
margin-top
:
12px
;
padding
:
8px
16px
;
background
:
var
(
--color-gray-1000
);
color
:
var
(
--color-background-100
);
border
:
none
;
border-radius
:
6px
;
font-size
:
var
(
--size-14
);
font-weight
:
500
;
cursor
:
pointer
;
width
:
100%
;
}
.suspense-profiler-modal-copy
:hover
{
opacity
:
0.9
;
}
packages/next/src/next-devtools/dev-overlay/components/overview/suspense-profiler.tsx
0 → 100644
View file @
d1226874
This diff is collapsed.
Click to expand it.
packages/next/src/next-devtools/dev-overlay/menu/context.tsx
View file @
d1226874
...
@@ -9,6 +9,7 @@ export type PanelStateKind =
...
@@ -9,6 +9,7 @@ export type PanelStateKind =
|
'preferences'
|
'preferences'
|
'route-type'
|
'route-type'
|
'segment-explorer'
|
'segment-explorer'
|
'suspense-profiler'
|
'panel-selector'
|
'panel-selector'
export
const
PanelRouterContext
=
createContext
<
{
export
const
PanelRouterContext
=
createContext
<
{
...
...
packages/next/src/next-devtools/dev-overlay/menu/panel-router.tsx
View file @
d1226874
...
@@ -6,7 +6,14 @@ import {
...
@@ -6,7 +6,14 @@ import {
RouteInfoBody
,
RouteInfoBody
,
}
from
'../components/errors/dev-tools-indicator/dev-tools-info/route-info'
}
from
'../components/errors/dev-tools-indicator/dev-tools-info/route-info'
import
{
PageSegmentTree
}
from
'../components/overview/segment-explorer'
import
{
PageSegmentTree
}
from
'../components/overview/segment-explorer'
import
{
SuspenseProfiler
}
from
'../components/overview/suspense-profiler'
import
{
DevToolsHeader
}
from
'../components/errors/dev-tools-indicator/dev-tools-info/dev-tools-header'
import
{
DevToolsHeader
}
from
'../components/errors/dev-tools-indicator/dev-tools-info/dev-tools-header'
// Check if suspense boundary data exists in the DOM
function
hasSuspenseData
():
boolean
{
if
(
typeof
document
===
'undefined'
)
return
false
return
document
.
getElementById
(
'__NEXT_SUSPENSE_BOUNDARIES__'
)
!==
null
}
import
{
useDelayedRender
}
from
'../hooks/use-delayed-render'
import
{
useDelayedRender
}
from
'../hooks/use-delayed-render'
import
{
import
{
MENU_CURVE
,
MENU_CURVE
,
...
@@ -112,6 +119,16 @@ const MenuPanel = () => {
...
@@ -112,6 +119,16 @@ const MenuPanel = () => {
'data-segment-explorer'
:
true
,
'data-segment-explorer'
:
true
,
},
},
},
},
isAppRouter
&&
hasSuspenseData
()
&&
{
label
:
'Suspense'
,
title
:
'View suspense boundaries and dynamic API calls'
,
value
:
<
ChevronRight
/>,
onClick
:
()
=>
setPanel
(
'suspense-profiler'
),
attributes
:
{
'data-suspense-profiler'
:
true
,
},
},
{
{
label
:
'Preferences'
,
label
:
'Preferences'
,
value
:
<
GearIcon
/>,
value
:
<
GearIcon
/>,
...
@@ -243,6 +260,30 @@ export const PanelRouter = () => {
...
@@ -243,6 +260,30 @@ export const PanelRouter = () => {
</
DynamicPanel
>
</
DynamicPanel
>
</
PanelRoute
>
</
PanelRoute
>
)
}
)
}
{
isAppRouter
&&
(
<
PanelRoute
name=
"suspense-profiler"
>
<
DynamicPanel
sharePanelSizeGlobally=
{
false
}
sharePanelPositionGlobally=
{
false
}
draggable
sizeConfig=
{
{
kind
:
'resizable'
,
maxHeight
:
'90vh'
,
maxWidth
:
'90vw'
,
minHeight
:
200
/
state
.
scale
,
minWidth
:
300
/
state
.
scale
,
initialSize
:
{
height
:
400
/
state
.
scale
,
width
:
400
/
state
.
scale
,
},
}
}
header=
{
<
DevToolsHeader
title=
"Suspense Profiler"
/>
}
>
<
SuspenseProfiler
/>
</
DynamicPanel
>
</
PanelRoute
>
)
}
</>
</>
)
)
}
}
...
...
packages/next/src/server/app-render/make-get-server-inserted-html.tsx
View file @
d1226874
...
@@ -12,7 +12,6 @@ import { RedirectStatusCode } from '../../client/components/redirect-status-code
...
@@ -12,7 +12,6 @@ import { RedirectStatusCode } from '../../client/components/redirect-status-code
import
{
addPathPrefix
}
from
'../../shared/lib/router/utils/add-path-prefix'
import
{
addPathPrefix
}
from
'../../shared/lib/router/utils/add-path-prefix'
import
type
{
ClientTraceDataEntry
}
from
'../lib/trace/tracer'
import
type
{
ClientTraceDataEntry
}
from
'../lib/trace/tracer'
import
{
SuspenseBoundaryScript
}
from
'./suspense-boundary-injector'
import
{
SuspenseBoundaryScript
}
from
'./suspense-boundary-injector'
import
{
getSuspenseBoundaries
}
from
'./suspense-boundary-collector'
export
function
makeGetServerInsertedHTML
({
export
function
makeGetServerInsertedHTML
({
polyfills
,
polyfills
,
...
@@ -28,6 +27,7 @@ export function makeGetServerInsertedHTML({
...
@@ -28,6 +27,7 @@ export function makeGetServerInsertedHTML({
basePath
:
string
basePath
:
string
})
{
})
{
let
flushedErrorMetaTagsUntilIndex
=
0
let
flushedErrorMetaTagsUntilIndex
=
0
let
suspenseBoundaryScriptFlushed
=
false
// These only need to be rendered once, they'll be set to empty arrays once flushed.
// These only need to be rendered once, they'll be set to empty arrays once flushed.
let
polyfillTags
=
polyfills
.
map
((
polyfill
)
=>
{
let
polyfillTags
=
polyfills
.
map
((
polyfill
)
=>
{
...
@@ -75,21 +75,23 @@ export function makeGetServerInsertedHTML({
...
@@ -75,21 +75,23 @@ export function makeGetServerInsertedHTML({
const
serverInsertedHTML
=
renderServerInsertedHTML
()
const
serverInsertedHTML
=
renderServerInsertedHTML
()
// Suspense boundary script should only be rendered once (on first flush).
// Boundaries are registered during React render, before streaming starts.
const
shouldRenderSuspenseScript
=
!
suspenseBoundaryScriptFlushed
if
(
shouldRenderSuspenseScript
)
{
suspenseBoundaryScriptFlushed
=
true
}
// Skip React rendering if we know the content is empty.
// Skip React rendering if we know the content is empty.
// Note: We can't skip when suspense profiling might be active since
// SuspenseBoundaryScript may have data to inject.
if
(
if
(
polyfillTags
.
length
===
0
&&
polyfillTags
.
length
===
0
&&
traceMetaTags
.
length
===
0
&&
traceMetaTags
.
length
===
0
&&
errorMetaTags
.
length
===
0
&&
errorMetaTags
.
length
===
0
&&
!
shouldRenderSuspenseScript
&&
Array
.
isArray
(
serverInsertedHTML
)
&&
Array
.
isArray
(
serverInsertedHTML
)
&&
serverInsertedHTML
.
length
===
0
serverInsertedHTML
.
length
===
0
)
{
)
{
// Check if there are any suspense boundaries to inject
return
''
const
boundaries
=
getSuspenseBoundaries
()
if
(
boundaries
.
length
===
0
)
{
return
''
}
}
}
const
stream
=
await
renderToReadableStream
(
const
stream
=
await
renderToReadableStream
(
...
@@ -98,7 +100,7 @@ export function makeGetServerInsertedHTML({
...
@@ -98,7 +100,7 @@ export function makeGetServerInsertedHTML({
{
serverInsertedHTML
}
{
serverInsertedHTML
}
{
traceMetaTags
}
{
traceMetaTags
}
{
errorMetaTags
}
{
errorMetaTags
}
<
SuspenseBoundaryScript
/>
{
shouldRenderSuspenseScript
&&
<
SuspenseBoundaryScript
/>
}
</>,
</>,
{
{
// Larger chunk because this isn't sent over the network.
// Larger chunk because this isn't sent over the network.
...
...
packages/next/src/server/app-render/suspense-boundary-injector.tsx
View file @
d1226874
This diff is collapsed.
Click to expand it.
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