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
eb506d6f
Commit
eb506d6f
authored
Jul 10, 2025
by
RobPruzan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: preprocess windows files correctly
parent
5e65f807
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
6 deletions
+37
-6
receive-logs.test.ts
...ges/next/src/server/dev/browser-logs/receive-logs.test.ts
+24
-0
source-map.ts
packages/next/src/server/dev/browser-logs/source-map.ts
+13
-6
No files found.
packages/next/src/server/dev/browser-logs/receive-logs.test.ts
View file @
eb506d6f
import
{
stripFormatSpecifiers
}
from
'./receive-logs'
import
{
stripFormatSpecifiers
}
from
'./receive-logs'
import
{
preprocessStackTrace
}
from
'./source-map'
describe
(
'stripFormatSpecifiers'
,
()
=>
{
describe
(
'stripFormatSpecifiers'
,
()
=>
{
it
(
'should only process when first arg is string containing %'
,
()
=>
{
it
(
'should only process when first arg is string containing %'
,
()
=>
{
...
@@ -72,3 +73,26 @@ describe('stripFormatSpecifiers', () => {
...
@@ -72,3 +73,26 @@ describe('stripFormatSpecifiers', () => {
expect
(
stripFormatSpecifiers
([
'ends with %'
])).
toEqual
([
'ends with %'
])
expect
(
stripFormatSpecifiers
([
'ends with %'
])).
toEqual
([
'ends with %'
])
})
})
})
})
describe
(
'preprocessStackTrace'
,
()
=>
{
it
(
'should convert _next/static paths to file URLs (posix)'
,
()
=>
{
const
input
=
' at myFunc (_next/static/chunks/app/page.js:1:1)'
const
distDir
=
'/project/.next'
const
output
=
preprocessStackTrace
(
input
,
distDir
)
expect
(
output
).
toContain
(
'file://'
)
expect
(
output
).
toContain
(
'/project/.next/static/chunks/app/page.js:1:1'
)
})
it
(
'should convert _next static paths with backslashes (windows) to file URLs'
,
()
=>
{
const
input
=
' at myFunc (_next
\\
static
\\
chunks
\\
app
\\
page.js:1:1)'
const
distDir
=
'/project/.next'
const
output
=
preprocessStackTrace
(
input
,
distDir
)
expect
(
output
).
toContain
(
'file://'
)
expect
(
output
).
toContain
(
'/project/.next/static/chunks/app/page.js:1:1'
)
expect
(
output
).
not
.
toContain
(
'_next/static'
)
expect
(
output
).
not
.
toContain
(
'
\
\'
)
})
})
packages/next/src/server/dev/browser-logs/source-map.ts
View file @
eb506d6f
...
@@ -79,22 +79,29 @@ export async function mapFramesUsingBundler(
...
@@ -79,22 +79,29 @@ export async function mapFramesUsingBundler(
// converts _next/static/chunks/... to file:///.next/static/chunks/... for parseStack
// converts _next/static/chunks/... to file:///.next/static/chunks/... for parseStack
// todo: where does next dev overlay handle this case and re-use that logic
// todo: where does next dev overlay handle this case and re-use that logic
function
preprocessStackTrace
(
stackTrace
:
string
,
distDir
?:
string
):
string
{
export
function
preprocessStackTrace
(
stackTrace
:
string
,
distDir
?:
string
):
string
{
const
toForwardSlashes
=
(
p
:
string
)
=>
p
.
replace
(
/
\\
/g
,
'/'
)
return
stackTrace
return
stackTrace
.
split
(
'
\
n'
)
.
split
(
'
\
n'
)
.
map
((
line
)
=>
{
.
map
((
line
)
=>
{
const
match
=
line
.
match
(
/^
(\s
*at
\s
+.*
?)\s
+
\(([^
)
]
+
)\)
$/
)
const
match
=
line
.
match
(
/^
(\s
*at
\s
+.*
?)\s
+
\(([^
)
]
+
)\)
$/
)
if
(
match
)
{
if
(
match
)
{
const
[,
prefix
,
location
]
=
match
const
[,
prefix
,
rawLocation
]
=
match
const
location
=
toForwardSlashes
(
rawLocation
)
if
(
location
.
startsWith
(
'_next/static/'
)
&&
distDir
)
{
if
(
location
.
startsWith
(
'_next/static/'
)
&&
distDir
)
{
const
normalizedDistDir
=
distDir
const
normalizedDistDir
=
toForwardSlashes
(
distDir
).
replace
(
/
\/
$/
,
''
)
.
replace
(
/
\\
/g
,
'/'
)
.
replace
(
/
\/
$/
,
''
)
const
absolutePath
=
const
absolutePath
=
normalizedDistDir
+
'/'
+
location
.
slice
(
'_next/'
.
length
)
normalizedDistDir
+
'/'
+
location
.
slice
(
'_next/'
.
length
)
const
fileUrl
=
`file://
${
path
.
resolve
(
absolutePath
)}
`
const
resolved
=
toForwardSlashes
(
path
.
resolve
(
absolutePath
))
const
fileUrl
=
`file://
${
resolved
}
`
return
`
${
prefix
}
(
${
fileUrl
}
)`
return
`
${
prefix
}
(
${
fileUrl
}
)`
}
}
...
...
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