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
Hide 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
export
const
HotlinkedText
:
React
.
FC
<
{
text
:
string
matcher
?:
(
text
:
string
)
=>
boolean
matcher
?:
(
text
:
string
)
=>
string
|
null
}
>
=
function
HotlinkedText
(
props
)
{
const
{
text
,
matcher
}
=
props
...
...
@@ -24,17 +24,27 @@ export const HotlinkedText: React.FC<{
if
(
linkRegex
.
test
(
rawPart
))
{
const
link
=
linkRegex
.
exec
(
rawPart
)
!
const
href
=
link
[
0
]
// If link matcher is present but the link doesn't match, don't turn it into a link
if
(
typeof
matcher
===
'function'
&&
!
matcher
(
href
))
{
return
(
<
React
.
Fragment
key=
{
`link-${outerIndex}-${index}`
}
>
{
rawPart
}
</
React
.
Fragment
>
)
// If link matcher is present, check if it returns a className
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
(
<
React
.
Fragment
key=
{
`link-${outerIndex}-${index}`
}
>
{
rawPart
}
</
React
.
Fragment
>
)
}
}
return
(
<
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
}
</
a
>
</
React
.
Fragment
>
...
...
packages/next/src/next-devtools/dev-overlay/container/errors.tsx
View file @
3f239eea
...
...
@@ -29,12 +29,18 @@ interface ErrorsProps extends ErrorBaseProps {
onClose
:
()
=>
void
}
function
isNextjsLink
(
text
:
string
):
boolean
{
return
text
.
startsWith
(
'https://nextjs.org'
)
function
matchLinkType
(
text
:
string
):
string
|
null
{
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
})
{
return
<
HotlinkedText
text=
{
message
}
matcher=
{
isNextjsLink
}
/>
return
<
HotlinkedText
text=
{
message
}
matcher=
{
matchLinkType
}
/>
}
function
GenericErrorDescription
({
error
}:
{
error
:
Error
})
{
...
...
@@ -51,7 +57,7 @@ function GenericErrorDescription({ error }: { error: Error }) {
return
(
<>
<
HotlinkedText
text=
{
message
}
matcher=
{
isNextjsLink
}
/>
<
HotlinkedText
text=
{
message
}
matcher=
{
matchLinkType
}
/>
</>
)
}
...
...
@@ -412,4 +418,7 @@ export const styles = `
border-radius: var(--rounded-md-2);
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', () => {
}
`
)
}
// Do not highlight example.com but do highlight nextjs.org
expect
(
await
session
.
evaluate
(
()
=>
...
...
@@ -898,7 +897,7 @@ describe('ReactRefreshLogBox app', () => {
.
shadowRoot
.
querySelectorAll
(
'#nextjs__container_errors_desc a'
)
.
length
)
).
toBe
(
1
)
).
toBe
(
2
)
expect
(
await
session
.
evaluate
(
()
=>
...
...
@@ -922,7 +921,7 @@ describe('ReactRefreshLogBox app', () => {
)
as
any
).
href
)
).
toBe
(
null
)
).
toBe
(
'http://example.com/'
)
})
// 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