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
afa34e93
Unverified
Commit
afa34e93
authored
Feb 18, 2025
by
Sebastian "Sebbie" Silbermann
Committed by
GitHub
Feb 18, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dev-overlay] Fix off-by-one column sourcemapping in Webpack (#76152)
parent
88601928
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
138 additions
and
248 deletions
+138
-248
parseNotFoundError.ts
...ack/plugins/wellknown-errors-plugin/parseNotFoundError.ts
+2
-1
middleware-turbopack.ts
...mponents/react-dev-overlay/server/middleware-turbopack.ts
+5
-1
middleware-webpack.ts
...components/react-dev-overlay/server/middleware-webpack.ts
+8
-9
capture-console-error-owner-stack.test.ts
...ror-owner-stack/capture-console-error-owner-stack.test.ts
+23
-73
error-ignored-frames.test.ts
...overlay/error-ignored-frames/error-ignored-frames.test.ts
+22
-22
owner-stack-invalid-element-type.test.ts
...lid-element-type/owner-stack-invalid-element-type.test.ts
+46
-101
owner-stack-react-missing-key-prop.test.ts
...ssing-key-prop/owner-stack-react-missing-key-prop.test.ts
+12
-12
owner-stack.test.ts
test/development/app-dir/owner-stack/owner-stack.test.ts
+9
-18
server-navigation-error.test.ts
...r/server-navigation-error/server-navigation-error.test.ts
+9
-9
use-cache-standalone-search-params.test.ts
...-search-params/use-cache-standalone-search-params.test.ts
+2
-2
No files found.
packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts
View file @
afa34e93
...
@@ -76,7 +76,8 @@ async function getSourceFrame(
...
@@ -76,7 +76,8 @@ async function getSourceFrame(
file
:
fileName
,
file
:
fileName
,
methodName
:
''
,
methodName
:
''
,
lineNumber
:
loc
.
start
.
line
,
lineNumber
:
loc
.
start
.
line
,
column
:
loc
.
start
.
column
,
// loc is 0-based but columns in stack frames are 1-based.
column
:
(
loc
.
start
.
column
??
0
)
+
1
,
},
},
})
})
...
...
packages/next/src/client/components/react-dev-overlay/server/middleware-turbopack.ts
View file @
afa34e93
...
@@ -232,6 +232,9 @@ function findApplicableSourceMapPayload(
...
@@ -232,6 +232,9 @@ function findApplicableSourceMapPayload(
}
}
}
}
/**
* @returns 1-based lines and 0-based columns
*/
async
function
nativeTraceSource
(
async
function
nativeTraceSource
(
frame
:
TurbopackStackFrame
frame
:
TurbopackStackFrame
):
Promise
<
{
frame
:
IgnorableStackFrame
;
source
:
string
|
null
}
|
undefined
>
{
):
Promise
<
{
frame
:
IgnorableStackFrame
;
source
:
string
|
null
}
|
undefined
>
{
...
@@ -264,7 +267,8 @@ async function nativeTraceSource(
...
@@ -264,7 +267,8 @@ async function nativeTraceSource(
try
{
try
{
const
originalPosition
=
consumer
.
originalPositionFor
({
const
originalPosition
=
consumer
.
originalPositionFor
({
line
:
frame
.
line
??
1
,
line
:
frame
.
line
??
1
,
column
:
frame
.
column
??
1
,
// 0-based columns out requires 0-based columns in.
column
:
(
frame
.
column
??
1
)
-
1
,
})
})
if
(
originalPosition
.
source
===
null
)
{
if
(
originalPosition
.
source
===
null
)
{
...
...
packages/next/src/client/components/react-dev-overlay/server/middleware-webpack.ts
View file @
afa34e93
...
@@ -90,9 +90,12 @@ function getSourcePath(source: string) {
...
@@ -90,9 +90,12 @@ function getSourcePath(source: string) {
return
source
.
replace
(
/^
(
webpack:
\/\/\/
|webpack:
\/\/
|webpack:
\/\/
_N_E
\/)
/
,
''
)
return
source
.
replace
(
/^
(
webpack:
\/\/\/
|webpack:
\/\/
|webpack:
\/\/
_N_E
\/)
/
,
''
)
}
}
/**
* @returns 1-based lines and 0-based columns
*/
async
function
findOriginalSourcePositionAndContent
(
async
function
findOriginalSourcePositionAndContent
(
sourceMap
:
RawSourceMap
,
sourceMap
:
RawSourceMap
,
position
:
{
line
:
number
;
column
:
number
|
null
}
position
:
{
line
Number
:
number
|
null
;
column
:
number
|
null
}
):
Promise
<
SourceAttributes
|
null
>
{
):
Promise
<
SourceAttributes
|
null
>
{
let
consumer
:
BasicSourceMapConsumer
let
consumer
:
BasicSourceMapConsumer
try
{
try
{
...
@@ -106,8 +109,9 @@ async function findOriginalSourcePositionAndContent(
...
@@ -106,8 +109,9 @@ async function findOriginalSourcePositionAndContent(
try
{
try
{
const
sourcePosition
=
consumer
.
originalPositionFor
({
const
sourcePosition
=
consumer
.
originalPositionFor
({
line
:
position
.
line
,
line
:
position
.
lineNumber
??
1
,
column
:
position
.
column
??
0
,
// 0-based columns out requires 0-based columns in.
column
:
(
position
.
column
??
1
)
-
1
,
})
})
if
(
!
sourcePosition
.
source
)
{
if
(
!
sourcePosition
.
source
)
{
...
@@ -191,7 +195,6 @@ export async function createOriginalStackFrame({
...
@@ -191,7 +195,6 @@ export async function createOriginalStackFrame({
frame
:
StackFrame
frame
:
StackFrame
errorMessage
?:
string
errorMessage
?:
string
}):
Promise
<
OriginalStackFrameResponse
|
null
>
{
}):
Promise
<
OriginalStackFrameResponse
|
null
>
{
const
{
lineNumber
,
column
}
=
frame
const
moduleNotFound
=
findModuleNotFoundFromError
(
errorMessage
)
const
moduleNotFound
=
findModuleNotFoundFromError
(
errorMessage
)
const
result
=
await
(()
=>
{
const
result
=
await
(()
=>
{
if
(
moduleNotFound
)
{
if
(
moduleNotFound
)
{
...
@@ -205,11 +208,7 @@ export async function createOriginalStackFrame({
...
@@ -205,11 +208,7 @@ export async function createOriginalStackFrame({
source
.
compilation
source
.
compilation
)
)
}
}
// This returns 1-based lines and 0-based columns
return
findOriginalSourcePositionAndContent
(
source
.
sourceMap
,
frame
)
return
findOriginalSourcePositionAndContent
(
source
.
sourceMap
,
{
line
:
lineNumber
??
1
,
column
,
})
})()
})()
if
(
!
result
)
{
if
(
!
result
)
{
...
...
test/development/app-dir/capture-console-error-owner-stack/capture-console-error-owner-stack.test.ts
View file @
afa34e93
...
@@ -41,54 +41,28 @@ describe('app-dir - capture-console-error-owner-stack', () => {
...
@@ -41,54 +41,28 @@ describe('app-dir - capture-console-error-owner-stack', () => {
const
result
=
await
getRedboxResult
(
browser
)
const
result
=
await
getRedboxResult
(
browser
)
// TODO(veil): Inconsistent cursor position for the "Page" frame
expect
(
result
).
toMatchInlineSnapshot
(
`
if
(
process
.
env
.
TURBOPACK
)
{
{
expect
(
result
).
toMatchInlineSnapshot
(
`
"callStacks": "onClick
{
app/browser/event/page.js (7:17)
"callStacks": "onClick
button
app/browser/event/page.js (7:17)
<anonymous> (0:0)
button
Page
<anonymous> (0:0)
app/browser/event/page.js (5:5)",
Page
"count": 1,
app/browser/event/page.js (5:5)",
"description": "trigger an console <error>",
"count": 1,
"source": "app/browser/event/page.js (7:17) @ onClick
"description": "trigger an console <error>",
"source": "app/browser/event/page.js (7:17) @ onClick
5 | <button
6 | onClick={() => {
5 | <button
> 7 | console.error('trigger an console <%s>', 'error')
6 | onClick={() => {
| ^
> 7 | console.error('trigger an console <%s>', 'error')
8 | }}
| ^
9 | >
8 | }}
10 | click to error",
9 | >
"title": "Console Error",
10 | click to error",
}
"title": "Console Error",
`
)
}
`
)
}
else
{
expect
(
result
).
toMatchInlineSnapshot
(
`
{
"callStacks": "onClick
app/browser/event/page.js (7:17)
button
<anonymous> (0:0)
Page
app/browser/event/page.js (5:6)",
"count": 1,
"description": "trigger an console <error>",
"source": "app/browser/event/page.js (7:17) @ onClick
5 | <button
6 | onClick={() => {
> 7 | console.error('trigger an console <%s>', 'error')
| ^
8 | }}
9 | >
10 | click to error",
"title": "Console Error",
}
`
)
}
})
})
it
(
'should capture browser console error in render and dedupe if necessary'
,
async
()
=>
{
it
(
'should capture browser console error in render and dedupe if necessary'
,
async
()
=>
{
...
@@ -227,30 +201,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
...
@@ -227,30 +201,7 @@ describe('app-dir - capture-console-error-owner-stack', () => {
}
}
`
)
`
)
}
else
{
}
else
{
if
(
process
.
env
.
TURBOPACK
)
{
expect
(
result
).
toMatchInlineSnapshot
(
`
expect
(
result
).
toMatchInlineSnapshot
(
`
{
"callStacks": "Page
app/rsc/page.js (2:17)
JSON.parse
<anonymous> (0:0)
Page
<anonymous> (0:0)",
"count": 1,
"description": "[ Server ] Error: boom",
"source": "app/rsc/page.js (2:17) @ Page
1 | export default function Page() {
> 2 | console.error(new Error('boom'))
| ^
3 | return <p>rsc</p>
4 | }
5 |",
"title": "Console Error",
}
`
)
}
else
{
expect
(
result
).
toMatchInlineSnapshot
(
`
{
{
"callStacks": "Page
"callStacks": "Page
app/rsc/page.js (2:17)
app/rsc/page.js (2:17)
...
@@ -271,7 +222,6 @@ describe('app-dir - capture-console-error-owner-stack', () => {
...
@@ -271,7 +222,6 @@ describe('app-dir - capture-console-error-owner-stack', () => {
"title": "Console Error",
"title": "Console Error",
}
}
`
)
`
)
}
}
}
})
})
...
...
test/development/app-dir/error-overlay/error-ignored-frames/error-ignored-frames.test.ts
View file @
afa34e93
...
@@ -6,7 +6,7 @@ import {
...
@@ -6,7 +6,7 @@ import {
}
from
'next-test-utils'
}
from
'next-test-utils'
describe
(
'error-ignored-frames'
,
()
=>
{
describe
(
'error-ignored-frames'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
const
{
isTurbopack
,
next
}
=
nextTestSetup
({
files
:
__dirname
,
files
:
__dirname
,
})
})
...
@@ -30,7 +30,7 @@ describe('error-ignored-frames', () => {
...
@@ -30,7 +30,7 @@ describe('error-ignored-frames', () => {
await
toggleCollapseCallStackFrames
(
browser
)
await
toggleCollapseCallStackFrames
(
browser
)
const
expendedStack
=
await
getStackFramesContent
(
browser
)
const
expendedStack
=
await
getStackFramesContent
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
"at Page (app/page.tsx (2:9))
"at Page (app/page.tsx (2:9))
at resolveErrorDev ()
at resolveErrorDev ()
...
@@ -50,11 +50,11 @@ describe('error-ignored-frames', () => {
...
@@ -50,11 +50,11 @@ describe('error-ignored-frames', () => {
at processFullStringRow ()
at processFullStringRow ()
at processFullBinaryRow ()
at processFullBinaryRow ()
at progress ()
at progress ()
at InnerLayoutRouter (../src/client/components/layout-router.tsx (408:
6
))
at InnerLayoutRouter (../src/client/components/layout-router.tsx (408:
5
))
at OuterLayoutRouter (../src/client/components/layout-router.tsx (607:
20
))
at OuterLayoutRouter (../src/client/components/layout-router.tsx (607:
19
))
at Router (../src/client/components/app-router.tsx (633:
8
))
at Router (../src/client/components/app-router.tsx (633:
7
))
at AppRouter (../src/client/components/app-router.tsx (679:
8
))
at AppRouter (../src/client/components/app-router.tsx (679:
7
))
at ServerRoot (../src/client/app-index.tsx (201:
6
))"
at ServerRoot (../src/client/app-index.tsx (201:
5
))"
`
)
`
)
}
}
})
})
...
@@ -71,7 +71,7 @@ describe('error-ignored-frames', () => {
...
@@ -71,7 +71,7 @@ describe('error-ignored-frames', () => {
await
toggleCollapseCallStackFrames
(
browser
)
await
toggleCollapseCallStackFrames
(
browser
)
const
expendedStack
=
await
getStackFramesContent
(
browser
)
const
expendedStack
=
await
getStackFramesContent
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
"at Page (app/client/page.tsx (4:9))
"at Page (app/client/page.tsx (4:9))
at ClientPageRoot ()
at ClientPageRoot ()
...
@@ -82,10 +82,10 @@ describe('error-ignored-frames', () => {
...
@@ -82,10 +82,10 @@ describe('error-ignored-frames', () => {
}
else
{
}
else
{
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
"at Page (app/client/page.tsx (4:9))
"at Page (app/client/page.tsx (4:9))
at ClientPageRoot (../src/client/components/client-page.tsx (60:1
3
))
at ClientPageRoot (../src/client/components/client-page.tsx (60:1
2
))
at Router (../src/client/components/app-router.tsx (633:
8
))
at Router (../src/client/components/app-router.tsx (633:
7
))
at AppRouter (../src/client/components/app-router.tsx (679:
8
))
at AppRouter (../src/client/components/app-router.tsx (679:
7
))
at ServerRoot (../src/client/app-index.tsx (201:
6
))"
at ServerRoot (../src/client/app-index.tsx (201:
5
))"
`
)
`
)
}
}
})
})
...
@@ -95,7 +95,7 @@ describe('error-ignored-frames', () => {
...
@@ -95,7 +95,7 @@ describe('error-ignored-frames', () => {
await
assertHasRedbox
(
browser
)
await
assertHasRedbox
(
browser
)
const
defaultStack
=
await
getStackFramesContent
(
browser
)
const
defaultStack
=
await
getStackFramesContent
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
defaultStack
).
toMatchInlineSnapshot
(
`
expect
(
defaultStack
).
toMatchInlineSnapshot
(
`
"at <unknown> (app/interleaved/page.tsx (7:11))
"at <unknown> (app/interleaved/page.tsx (7:11))
at Page (app/interleaved/page.tsx (6:35))"
at Page (app/interleaved/page.tsx (6:35))"
...
@@ -103,18 +103,18 @@ describe('error-ignored-frames', () => {
...
@@ -103,18 +103,18 @@ describe('error-ignored-frames', () => {
}
else
{
}
else
{
expect
(
defaultStack
).
toMatchInlineSnapshot
(
`
expect
(
defaultStack
).
toMatchInlineSnapshot
(
`
"at eval (app/interleaved/page.tsx (7:11))
"at eval (app/interleaved/page.tsx (7:11))
at Page (app/interleaved/page.tsx (6:3
7
))"
at Page (app/interleaved/page.tsx (6:3
6
))"
`
)
`
)
}
}
await
toggleCollapseCallStackFrames
(
browser
)
await
toggleCollapseCallStackFrames
(
browser
)
const
expendedStack
=
await
getStackFramesContent
(
browser
)
const
expendedStack
=
await
getStackFramesContent
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
"at <unknown> (app/interleaved/page.tsx (7:11))
"at <unknown> (app/interleaved/page.tsx (7:11))
at invokeCallback ()
at Page (app/interleaved/page.tsx (6:35))
at Page (app/interleaved/page.tsx (6:35))
at invokeCallback ()
at ClientPageRoot ()
at ClientPageRoot ()
at Router ()
at Router ()
at AppRouter ()
at AppRouter ()
...
@@ -124,11 +124,11 @@ describe('error-ignored-frames', () => {
...
@@ -124,11 +124,11 @@ describe('error-ignored-frames', () => {
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
"at eval (app/interleaved/page.tsx (7:11))
"at eval (app/interleaved/page.tsx (7:11))
at invokeCallback (node_modules/interleave/index.js (2:1))
at invokeCallback (node_modules/interleave/index.js (2:1))
at Page (app/interleaved/page.tsx (6:3
7
))
at Page (app/interleaved/page.tsx (6:3
6
))
at ClientPageRoot (../src/client/components/client-page.tsx (60:1
3
))
at ClientPageRoot (../src/client/components/client-page.tsx (60:1
2
))
at Router (../src/client/components/app-router.tsx (633:
8
))
at Router (../src/client/components/app-router.tsx (633:
7
))
at AppRouter (../src/client/components/app-router.tsx (679:
8
))
at AppRouter (../src/client/components/app-router.tsx (679:
7
))
at ServerRoot (../src/client/app-index.tsx (201:
6
))"
at ServerRoot (../src/client/app-index.tsx (201:
5
))"
`
)
`
)
}
}
})
})
...
@@ -145,7 +145,7 @@ describe('error-ignored-frames', () => {
...
@@ -145,7 +145,7 @@ describe('error-ignored-frames', () => {
await
toggleCollapseCallStackFrames
(
browser
)
await
toggleCollapseCallStackFrames
(
browser
)
const
expendedStack
=
await
getStackFramesContent
(
browser
)
const
expendedStack
=
await
getStackFramesContent
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
expect
(
expendedStack
).
toMatchInlineSnapshot
(
`
"at Page (pages/pages.tsx (2:9))
"at Page (pages/pages.tsx (2:9))
at react-stack-bottom-frame ()
at react-stack-bottom-frame ()
...
...
test/development/app-dir/owner-stack-invalid-element-type/owner-stack-invalid-element-type.test.ts
View file @
afa34e93
...
@@ -17,41 +17,22 @@ describe('app-dir - owner-stack-invalid-element-type', () => {
...
@@ -17,41 +17,22 @@ describe('app-dir - owner-stack-invalid-element-type', () => {
const
source
=
await
getRedboxSource
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at BrowserOnly (app/browser/browser-only.js (8:7))
"at BrowserOnly (app/browser/browser-only.js (8:7))
at Inner (app/browser/page.js (11:10))
at Inner (app/browser/page.js (11:10))
at Page (app/browser/page.js (15:10))"
at Page (app/browser/page.js (15:10))"
`
)
`
)
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"app/browser/browser-only.js (8:7) @ BrowserOnly
"app/browser/browser-only.js (8:7) @ BrowserOnly
6 | return (
6 | return (
7 | <div>
7 | <div>
> 8 | <Foo />
> 8 | <Foo />
| ^
| ^
9 | </div>
9 | </div>
10 | )
10 | )
11 | }"
11 | }"
`
)
`
)
}
else
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at BrowserOnly (app/browser/browser-only.js (8:8))
at Inner (app/browser/page.js (11:11))
at Page (app/browser/page.js (15:11))"
`
)
expect
(
source
).
toMatchInlineSnapshot
(
`
"app/browser/browser-only.js (8:8) @ BrowserOnly
6 | return (
7 | <div>
> 8 | <Foo />
| ^
9 | </div>
10 | )
11 | }"
`
)
}
})
})
it
(
'should catch invalid element from a rsc component'
,
async
()
=>
{
it
(
'should catch invalid element from a rsc component'
,
async
()
=>
{
...
@@ -61,39 +42,21 @@ describe('app-dir - owner-stack-invalid-element-type', () => {
...
@@ -61,39 +42,21 @@ describe('app-dir - owner-stack-invalid-element-type', () => {
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at Inner (app/rsc/page.js (5:10))
"at Inner (app/rsc/page.js (5:11))
at Page (app/rsc/page.js (11:7))"
at Page (app/rsc/page.js (11:8))"
`
)
`
)
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"app/rsc/page.js (5:10) @ Inner
"app/rsc/page.js (5:11) @ Inner
3 | // Intermediate component for testing owner stack
3 | // Intermediate component for testing owner stack
4 | function Inner() {
4 | function Inner() {
> 5 | return <Foo />
> 5 | return <Foo />
| ^
| ^
6 | }
6 | }
7 |
7 |
8 | export default function Page() {"
8 | export default function Page() {"
`
)
`
)
}
else
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at Inner (app/rsc/page.js (5:11))
at Page (app/rsc/page.js (11:8))"
`
)
expect
(
source
).
toMatchInlineSnapshot
(
`
"app/rsc/page.js (5:11) @ Inner
3 | // Intermediate component for testing owner stack
4 | function Inner() {
> 5 | return <Foo />
| ^
6 | }
7 |
8 | export default function Page() {"
`
)
}
})
})
it
(
'should catch invalid element from on ssr client component'
,
async
()
=>
{
it
(
'should catch invalid element from on ssr client component'
,
async
()
=>
{
...
@@ -103,38 +66,20 @@ describe('app-dir - owner-stack-invalid-element-type', () => {
...
@@ -103,38 +66,20 @@ describe('app-dir - owner-stack-invalid-element-type', () => {
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at Inner (app/ssr/page.js (7:10))
"at Inner (app/ssr/page.js (7:10))
at Page (app/ssr/page.js (13:7))"
at Page (app/ssr/page.js (13:7))"
`
)
`
)
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"app/ssr/page.js (7:10) @ Inner
"app/ssr/page.js (7:10) @ Inner
5 | // Intermediate component for testing owner stack
5 | // Intermediate component for testing owner stack
6 | function Inner() {
6 | function Inner() {
> 7 | return <Foo />
> 7 | return <Foo />
| ^
| ^
8 | }
8 | }
9 |
9 |
10 | export default function Page() {"
10 | export default function Page() {"
`
)
`
)
}
else
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at Inner (app/ssr/page.js (7:11))
at Page (app/ssr/page.js (13:8))"
`
)
expect
(
source
).
toMatchInlineSnapshot
(
`
"app/ssr/page.js (7:11) @ Inner
5 | // Intermediate component for testing owner stack
6 | function Inner() {
> 7 | return <Foo />
| ^
8 | }
9 |
10 | export default function Page() {"
`
)
}
})
})
})
})
test/development/app-dir/owner-stack-react-missing-key-prop/owner-stack-react-missing-key-prop.test.ts
View file @
afa34e93
...
@@ -6,7 +6,7 @@ import {
...
@@ -6,7 +6,7 @@ import {
}
from
'next-test-utils'
}
from
'next-test-utils'
describe
(
'app-dir - owner-stack-react-missing-key-prop'
,
()
=>
{
describe
(
'app-dir - owner-stack-react-missing-key-prop'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
const
{
isTurbopack
,
next
}
=
nextTestSetup
({
files
:
__dirname
,
files
:
__dirname
,
})
})
...
@@ -17,19 +17,19 @@ describe('app-dir - owner-stack-react-missing-key-prop', () => {
...
@@ -17,19 +17,19 @@ describe('app-dir - owner-stack-react-missing-key-prop', () => {
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at span ()
"at span ()
at <anonymous> (app/rsc/page.tsx (7:
10
))
at <anonymous> (app/rsc/page.tsx (7:
9
))
at Page (app/rsc/page.tsx (6:13))"
at Page (app/rsc/page.tsx (6:13))"
`
)
`
)
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"app/rsc/page.tsx (7:
10
) @ <anonymous>
"app/rsc/page.tsx (7:
9
) @ <anonymous>
5 | <div>
5 | <div>
6 | {list.map((item, index) => (
6 | {list.map((item, index) => (
> 7 | <span>{item}</span>
> 7 | <span>{item}</span>
|
^
| ^
8 | ))}
8 | ))}
9 | </div>
9 | </div>
10 | )"
10 | )"
...
@@ -37,16 +37,16 @@ describe('app-dir - owner-stack-react-missing-key-prop', () => {
...
@@ -37,16 +37,16 @@ describe('app-dir - owner-stack-react-missing-key-prop', () => {
}
else
{
}
else
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at span ()
"at span ()
at eval (app/rsc/page.tsx (7:
10
))
at eval (app/rsc/page.tsx (7:
9
))
at Page (app/rsc/page.tsx (6:13))"
at Page (app/rsc/page.tsx (6:13))"
`
)
`
)
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"app/rsc/page.tsx (7:
10
) @ eval
"app/rsc/page.tsx (7:
9
) @ eval
5 | <div>
5 | <div>
6 | {list.map((item, index) => (
6 | {list.map((item, index) => (
> 7 | <span>{item}</span>
> 7 | <span>{item}</span>
|
^
| ^
8 | ))}
8 | ))}
9 | </div>
9 | </div>
10 | )"
10 | )"
...
@@ -60,7 +60,7 @@ describe('app-dir - owner-stack-react-missing-key-prop', () => {
...
@@ -60,7 +60,7 @@ describe('app-dir - owner-stack-react-missing-key-prop', () => {
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at p ()
"at p ()
at <unknown> (app/ssr/page.tsx (9:9))
at <unknown> (app/ssr/page.tsx (9:9))
...
@@ -81,17 +81,17 @@ describe('app-dir - owner-stack-react-missing-key-prop', () => {
...
@@ -81,17 +81,17 @@ describe('app-dir - owner-stack-react-missing-key-prop', () => {
}
else
{
}
else
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at p ()
"at p ()
at eval (app/ssr/page.tsx (9:
10
))
at eval (app/ssr/page.tsx (9:
9
))
at Array.map ()
at Array.map ()
at Page (app/ssr/page.tsx (8:13))"
at Page (app/ssr/page.tsx (8:13))"
`
)
`
)
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"app/ssr/page.tsx (9:
10
) @ eval
"app/ssr/page.tsx (9:
9
) @ eval
7 | <div>
7 | <div>
8 | {list.map((item, index) => (
8 | {list.map((item, index) => (
> 9 | <p>{item}</p>
> 9 | <p>{item}</p>
|
^
| ^
10 | ))}
10 | ))}
11 | </div>
11 | </div>
12 | )"
12 | )"
...
...
test/development/app-dir/owner-stack/owner-stack.test.ts
View file @
afa34e93
...
@@ -47,7 +47,7 @@ async function getStackFramesContent(browser) {
...
@@ -47,7 +47,7 @@ async function getStackFramesContent(browser) {
}
}
describe
(
'app-dir - owner-stack'
,
()
=>
{
describe
(
'app-dir - owner-stack'
,
()
=>
{
const
{
isTurbopack
,
next
}
=
nextTestSetup
({
const
{
next
}
=
nextTestSetup
({
files
:
__dirname
,
files
:
__dirname
,
})
})
...
@@ -168,23 +168,14 @@ describe('app-dir - owner-stack', () => {
...
@@ -168,23 +168,14 @@ describe('app-dir - owner-stack', () => {
await
openRedbox
(
browser
)
await
openRedbox
(
browser
)
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
const
stackFramesContent
=
await
getStackFramesContent
(
browser
)
if
(
isTurbopack
)
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at useThrowError (app/browser/caught/page.js (34:11))
"at useThrowError (app/browser/caught/page.js (34:11))
at useErrorHook (app/browser/caught/page.js (39:3))
at useErrorHook (app/browser/caught/page.js (39:3))
at Thrower (app/browser/caught/page.js (29:3))
at Thrower (app/browser/caught/page.js (29:3))
at Inner (app/browser/caught/page.js (23:7))
at Inner (app/browser/caught/page.js (23:7))
at Page (app/browser/caught/page.js (43:10))"
at Page (app/browser/caught/page.js (43:10))"
`
)
`
)
}
else
{
expect
(
stackFramesContent
).
toMatchInlineSnapshot
(
`
"at useThrowError (app/browser/caught/page.js (34:11))
at useErrorHook (app/browser/caught/page.js (39:3))
at Thrower (app/browser/caught/page.js (29:3))
at Inner (app/browser/caught/page.js (23:8))
at Page (app/browser/caught/page.js (43:11))"
`
)
}
expect
(
normalizeStackTrace
(
errorLog
)).
toMatchInlineSnapshot
(
`
expect
(
normalizeStackTrace
(
errorLog
)).
toMatchInlineSnapshot
(
`
"%o
"%o
...
...
test/development/app-dir/server-navigation-error/server-navigation-error.test.ts
View file @
afa34e93
...
@@ -6,7 +6,7 @@ import {
...
@@ -6,7 +6,7 @@ import {
}
from
'next-test-utils'
}
from
'next-test-utils'
describe
(
'server-navigation-error'
,
()
=>
{
describe
(
'server-navigation-error'
,
()
=>
{
const
{
next
}
=
nextTestSetup
({
const
{
isTurbopack
,
next
}
=
nextTestSetup
({
files
:
__dirname
,
files
:
__dirname
,
})
})
...
@@ -18,7 +18,7 @@ describe('server-navigation-error', () => {
...
@@ -18,7 +18,7 @@ describe('server-navigation-error', () => {
`Next.js navigation API is not allowed to be used in Pages Router.`
`Next.js navigation API is not allowed to be used in Pages Router.`
)
)
const
source
=
await
getRedboxSource
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"pages/pages/redirect.tsx (4:10) @ Page
"pages/pages/redirect.tsx (4:10) @ Page
...
@@ -31,12 +31,12 @@ describe('server-navigation-error', () => {
...
@@ -31,12 +31,12 @@ describe('server-navigation-error', () => {
`
)
`
)
}
else
{
}
else
{
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"pages/pages/redirect.tsx (4:1
2
) @ Page
"pages/pages/redirect.tsx (4:1
1
) @ Page
2 |
2 |
3 | export default function Page() {
3 | export default function Page() {
> 4 | redirect('/')
> 4 | redirect('/')
|
^
| ^
5 | }
5 | }
6 |"
6 |"
`
)
`
)
...
@@ -50,7 +50,7 @@ describe('server-navigation-error', () => {
...
@@ -50,7 +50,7 @@ describe('server-navigation-error', () => {
`Next.js navigation API is not allowed to be used in Pages Router.`
`Next.js navigation API is not allowed to be used in Pages Router.`
)
)
const
source
=
await
getRedboxSource
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"pages/pages/not-found.tsx (4:10) @ Page
"pages/pages/not-found.tsx (4:10) @ Page
...
@@ -86,7 +86,7 @@ describe('server-navigation-error', () => {
...
@@ -86,7 +86,7 @@ describe('server-navigation-error', () => {
`Next.js navigation API is not allowed to be used in Middleware.`
`Next.js navigation API is not allowed to be used in Middleware.`
)
)
const
source
=
await
getRedboxSource
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"middleware.ts (8:12) @ middleware
"middleware.ts (8:12) @ middleware
...
@@ -100,12 +100,12 @@ describe('server-navigation-error', () => {
...
@@ -100,12 +100,12 @@ describe('server-navigation-error', () => {
`
)
`
)
}
else
{
}
else
{
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"middleware.ts (8:1
4
) @ middleware
"middleware.ts (8:1
3
) @ middleware
6 | notFound()
6 | notFound()
7 | } else if (req.nextUrl.pathname === '/middleware/redirect') {
7 | } else if (req.nextUrl.pathname === '/middleware/redirect') {
> 8 | redirect('/')
> 8 | redirect('/')
|
^
| ^
9 | }
9 | }
10 | }
10 | }
11 |"
11 |"
...
@@ -121,7 +121,7 @@ describe('server-navigation-error', () => {
...
@@ -121,7 +121,7 @@ describe('server-navigation-error', () => {
)
)
const
source
=
await
getRedboxSource
(
browser
)
const
source
=
await
getRedboxSource
(
browser
)
if
(
process
.
env
.
TURBOPACK
)
{
if
(
isTurbopack
)
{
expect
(
source
).
toMatchInlineSnapshot
(
`
expect
(
source
).
toMatchInlineSnapshot
(
`
"middleware.ts (6:12) @ middleware
"middleware.ts (6:12) @ middleware
...
...
test/e2e/app-dir/use-cache-standalone-search-params/use-cache-standalone-search-params.test.ts
View file @
afa34e93
...
@@ -56,12 +56,12 @@ describe('use-cache-standalone-search-params', () => {
...
@@ -56,12 +56,12 @@ describe('use-cache-standalone-search-params', () => {
at Page (file:/`
)
at Page (file:/`
)
}
else
{
}
else
{
expect
(
errorSource
).
toMatchInlineSnapshot
(
`
expect
(
errorSource
).
toMatchInlineSnapshot
(
`
"app/search-params-used/page.tsx (8:1
8
) @ Page
"app/search-params-used/page.tsx (8:1
7
) @ Page
6 | searchParams: Promise<{ [key: string]: string | string[] | undefined }>
6 | searchParams: Promise<{ [key: string]: string | string[] | undefined }>
7 | }) {
7 | }) {
> 8 | const param = (await searchParams).foo
> 8 | const param = (await searchParams).foo
|
^
| ^
9 |
9 |
10 | return <p>param: {param}</p>
10 | return <p>param: {param}</p>
11 | }"
11 | }"
...
...
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