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
3f239eea
Unverified
Commit
3f239eea
authored
Nov 13, 2025
by
Jiachi Liu
Committed by
GitHub
Nov 13, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[devtool] highlight all link in error message (#86084)
parent
5e7a207b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
16 deletions
+34
-16
index.tsx
...devtools/dev-overlay/components/hot-linked-text/index.tsx
+19
-9
errors.tsx
...s/next/src/next-devtools/dev-overlay/container/errors.tsx
+13
-4
ReactRefreshLogBox.test.ts
test/development/acceptance-app/ReactRefreshLogBox.test.ts
+2
-3
No files found.
packages/next/src/next-devtools/dev-overlay/components/hot-linked-text/index.tsx
View file @
3f239eea
...
@@ -5,7 +5,7 @@ const linkRegex = /https?:\/\/[^\s/$.?#].[^\s)'"]*/i
...
@@ -5,7 +5,7 @@ const linkRegex = /https?:\/\/[^\s/$.?#].[^\s)'"]*/i
export
const
HotlinkedText
:
React
.
FC
<
{
export
const
HotlinkedText
:
React
.
FC
<
{
text
:
string
text
:
string
matcher
?:
(
text
:
string
)
=>
boolean
matcher
?:
(
text
:
string
)
=>
string
|
null
}
>
=
function
HotlinkedText
(
props
)
{
}
>
=
function
HotlinkedText
(
props
)
{
const
{
text
,
matcher
}
=
props
const
{
text
,
matcher
}
=
props
...
@@ -24,17 +24,27 @@ export const HotlinkedText: React.FC<{
...
@@ -24,17 +24,27 @@ export const HotlinkedText: React.FC<{
if
(
linkRegex
.
test
(
rawPart
))
{
if
(
linkRegex
.
test
(
rawPart
))
{
const
link
=
linkRegex
.
exec
(
rawPart
)
!
const
link
=
linkRegex
.
exec
(
rawPart
)
!
const
href
=
link
[
0
]
const
href
=
link
[
0
]
// If link matcher is present but the link doesn't match, don't turn it into a link
// If link matcher is present, check if it returns a className
if
(
typeof
matcher
===
'function'
&&
!
matcher
(
href
))
{
let
linkClassName
:
string
|
null
=
null
if
(
typeof
matcher
===
'function'
)
{
linkClassName
=
matcher
(
href
)
// If matcher returns null, don't turn it into a link
if
(
linkClassName
===
null
)
{
return
(
return
(
<
React
.
Fragment
key=
{
`link-${outerIndex}-${index}`
}
>
<
React
.
Fragment
key=
{
`link-${outerIndex}-${index}`
}
>
{
rawPart
}
{
rawPart
}
</
React
.
Fragment
>
</
React
.
Fragment
>
)
)
}
}
}
return
(
return
(
<
React
.
Fragment
key=
{
`link-${outerIndex}-${index}`
}
>
<
React
.
Fragment
key=
{
`link-${outerIndex}-${index}`
}
>
<
a
href=
{
href
}
target=
"_blank"
rel=
"noreferrer noopener"
>
<
a
href=
{
href
}
target=
"_blank"
rel=
"noreferrer noopener"
className=
{
linkClassName
||
undefined
}
>
{
rawPart
}
{
rawPart
}
</
a
>
</
a
>
</
React
.
Fragment
>
</
React
.
Fragment
>
...
...
packages/next/src/next-devtools/dev-overlay/container/errors.tsx
View file @
3f239eea
...
@@ -29,12 +29,18 @@ interface ErrorsProps extends ErrorBaseProps {
...
@@ -29,12 +29,18 @@ interface ErrorsProps extends ErrorBaseProps {
onClose
:
()
=>
void
onClose
:
()
=>
void
}
}
function
isNextjsLink
(
text
:
string
):
boolean
{
function
matchLinkType
(
text
:
string
):
string
|
null
{
return
text
.
startsWith
(
'https://nextjs.org'
)
if
(
text
.
startsWith
(
'https://nextjs.org'
))
{
return
'nextjs-link'
}
if
(
text
.
startsWith
(
'https://'
)
||
text
.
startsWith
(
'http://'
))
{
return
'external-link'
}
return
null
}
}
function
HydrationErrorDescription
({
message
}:
{
message
:
string
})
{
function
HydrationErrorDescription
({
message
}:
{
message
:
string
})
{
return
<
HotlinkedText
text=
{
message
}
matcher=
{
isNextjsLink
}
/>
return
<
HotlinkedText
text=
{
message
}
matcher=
{
matchLinkType
}
/>
}
}
function
GenericErrorDescription
({
error
}:
{
error
:
Error
})
{
function
GenericErrorDescription
({
error
}:
{
error
:
Error
})
{
...
@@ -51,7 +57,7 @@ function GenericErrorDescription({ error }: { error: Error }) {
...
@@ -51,7 +57,7 @@ function GenericErrorDescription({ error }: { error: Error }) {
return
(
return
(
<>
<>
<
HotlinkedText
text=
{
message
}
matcher=
{
isNextjsLink
}
/>
<
HotlinkedText
text=
{
message
}
matcher=
{
matchLinkType
}
/>
</>
</>
)
)
}
}
...
@@ -412,4 +418,7 @@ export const styles = `
...
@@ -412,4 +418,7 @@ export const styles = `
border-radius: var(--rounded-md-2);
border-radius: var(--rounded-md-2);
border: 1px solid var(--color-gray-alpha-400);
border: 1px solid var(--color-gray-alpha-400);
}
}
.external-link, .external-link:hover {
color:inherit;
}
`
`
test/development/acceptance-app/ReactRefreshLogBox.test.ts
View file @
3f239eea
...
@@ -889,7 +889,6 @@ describe('ReactRefreshLogBox app', () => {
...
@@ -889,7 +889,6 @@ describe('ReactRefreshLogBox app', () => {
}
}
`
)
`
)
}
}
// Do not highlight example.com but do highlight nextjs.org
expect
(
expect
(
await
session
.
evaluate
(
await
session
.
evaluate
(
()
=>
()
=>
...
@@ -898,7 +897,7 @@ describe('ReactRefreshLogBox app', () => {
...
@@ -898,7 +897,7 @@ describe('ReactRefreshLogBox app', () => {
.
shadowRoot
.
querySelectorAll
(
'#nextjs__container_errors_desc a'
)
.
shadowRoot
.
querySelectorAll
(
'#nextjs__container_errors_desc a'
)
.
length
.
length
)
)
).
toBe
(
1
)
).
toBe
(
2
)
expect
(
expect
(
await
session
.
evaluate
(
await
session
.
evaluate
(
()
=>
()
=>
...
@@ -922,7 +921,7 @@ describe('ReactRefreshLogBox app', () => {
...
@@ -922,7 +921,7 @@ describe('ReactRefreshLogBox app', () => {
)
as
any
)
as
any
).
href
).
href
)
)
).
toBe
(
null
)
).
toBe
(
'http://example.com/'
)
})
})
// TODO-APP: Catch errors that happen before useEffect
// TODO-APP: Catch errors that happen before useEffect
...
...
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