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
a4bc6f7a
Unverified
Commit
a4bc6f7a
authored
Oct 26, 2026
by
vercel-fleet-prod[bot]
Committed by
GitHub
Oct 26, 2026
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
address route loader review feedback
Co-authored-by:
Tobias Koppers
<
1365881+sokra@users.noreply.github.com
>
parent
5b4b95e2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
27 deletions
+61
-27
next-turbopack.ts
packages/next/src/client/next-turbopack.ts
+26
-14
pages-router-route-loader-chunk-delay.test.ts
...chunk-delay/pages-router-route-loader-chunk-delay.test.ts
+25
-12
track.module.css
...es-router-route-loader-chunk-delay/pages/track.module.css
+3
-0
track.tsx
...e2e/pages-router-route-loader-chunk-delay/pages/track.tsx
+7
-1
No files found.
packages/next/src/client/next-turbopack.ts
View file @
a4bc6f7a
...
@@ -24,6 +24,18 @@ declare let __turbopack_load__: any
...
@@ -24,6 +24,18 @@ declare let __turbopack_load__: any
type
PageChunkData
=
string
|
{
path
:
string
}
type
PageChunkData
=
string
|
{
path
:
string
}
function
isChunkScriptInDocument
(
chunkPath
:
string
):
boolean
{
const
expectedPath
=
'/_next/'
+
chunkPath
return
Array
.
from
(
document
.
scripts
).
some
((
script
)
=>
{
if
(
!
script
.
src
)
return
false
try
{
return
new
URL
(
script
.
src
).
pathname
.
endsWith
(
expectedPath
)
}
catch
{
return
false
}
})
}
// Map of page route -> promise that settles once the page's executable chunks
// Map of page route -> promise that settles once the page's executable chunks
// finish loading. The route loader consumes these promises in production.
// finish loading. The route loader consumes these promises in production.
// Creating the map eagerly also lets the route loader detect Turbopack.
// Creating the map eagerly also lets the route loader detect Turbopack.
...
@@ -37,27 +49,27 @@ initialize({})
...
@@ -37,27 +49,27 @@ initialize({})
page
:
string
,
page
:
string
,
chunksData
:
PageChunkData
[]
chunksData
:
PageChunkData
[]
)
=>
{
)
=>
{
const
chunkLoads
=
chunksData
.
map
((
chunkData
)
=>
({
const
chunkLoads
=
chunksData
.
map
((
chunkData
)
=>
{
chunkData
,
const
chunkPath
=
promise
:
__turbopack_load__
(
chunkData
),
typeof
chunkData
===
'string'
?
chunkData
:
chunkData
.
path
}))
const
shouldDelayTimeout
=
!
chunkPath
.
endsWith
(
'.css'
)
&&
!
isChunkScriptInDocument
(
chunkPath
)
return
{
shouldDelayTimeout
,
promise
:
__turbopack_load__
(
chunkData
),
}
})
// Preserve loading and error reporting for every chunk. CSS remains
// Preserve loading and error reporting for every chunk. CSS remains
// subject to the route timeout, and the shared runtime is already active,
// subject to the route timeout, and scripts already in the document do
// so only executable page chunks postpone that timeout.
// not represent new page work. Only newly requested executable chunks
// postpone that timeout.
Promise
.
all
(
chunkLoads
.
map
(({
promise
})
=>
promise
)).
catch
((
err
)
=>
Promise
.
all
(
chunkLoads
.
map
(({
promise
})
=>
promise
)).
catch
((
err
)
=>
console
.
error
(
'failed to load chunks for page '
+
page
,
err
)
console
.
error
(
'failed to load chunks for page '
+
page
,
err
)
)
)
const
chunksPromise
=
Promise
.
all
(
const
chunksPromise
=
Promise
.
all
(
chunkLoads
chunkLoads
.
filter
(({
chunkData
})
=>
{
.
filter
(({
shouldDelayTimeout
})
=>
shouldDelayTimeout
)
const
chunkPath
=
typeof
chunkData
===
'string'
?
chunkData
:
chunkData
.
path
return
(
!
chunkPath
.
endsWith
(
'.css'
)
&&
!
/
(?:
^|
\/)
turbopack-
[^/]
+
\.
js$/
.
test
(
chunkPath
)
)
})
.
map
(({
promise
})
=>
promise
)
.
map
(({
promise
})
=>
promise
)
).
catch
(()
=>
{})
).
catch
(()
=>
{})
turbopackPageChunkPromises
.
set
(
page
,
chunksPromise
)
turbopackPageChunkPromises
.
set
(
page
,
chunksPromise
)
...
...
test/e2e/pages-router-route-loader-chunk-delay/pages-router-route-loader-chunk-delay.test.ts
View file @
a4bc6f7a
...
@@ -21,7 +21,9 @@ describe('pages-router-route-loader-chunk-delay', () => {
...
@@ -21,7 +21,9 @@ describe('pages-router-route-loader-chunk-delay', () => {
files
:
__dirname
,
files
:
__dirname
,
})
})
it
(
'should not time out when /_next/static chunks load slowly'
,
async
()
=>
{
async
function
loadTrackWithDelayedAssets
(
pattern
:
string
):
Promise
<
{
ok
:
boolean
;
message
?:
string
}
>
{
const
delayMs
=
5000
const
delayMs
=
5000
let
playwrightPage
:
Page
|
undefined
let
playwrightPage
:
Page
|
undefined
...
@@ -36,24 +38,35 @@ describe('pages-router-route-loader-chunk-delay', () => {
...
@@ -36,24 +38,35 @@ describe('pages-router-route-loader-chunk-delay', () => {
})
})
if
(
!
playwrightPage
)
throw
new
Error
(
'playwrightPage was not captured'
)
if
(
!
playwrightPage
)
throw
new
Error
(
'playwrightPage was not captured'
)
await
playwrightPage
.
route
(
'**/_next/static/**/*.js*'
,
async
(
route
)
=>
{
await
playwrightPage
.
route
(
pattern
,
async
(
route
)
=>
{
await
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
delayMs
))
await
new
Promise
((
resolve
)
=>
setTimeout
(
resolve
,
delayMs
))
await
route
.
continue
()
await
route
.
continue
()
})
})
// `router.push` masks this failure by falling back to a hard navigation,
// `router.push` masks this failure by falling back to a hard navigation,
// so call the underlying page loader directly.
// so call the underlying page loader directly.
const
result
:
{
ok
:
boolean
;
message
?:
string
}
=
await
browser
.
eval
<
any
>
(
return
browser
.
eval
<
any
>
(
async
()
=>
{
async
()
=>
{
try
{
try
{
await
(
window
as
any
).
next
.
router
.
pageLoader
.
loadPage
(
'/track'
)
await
(
window
as
any
).
next
.
router
.
pageLoader
.
loadPage
(
'/track'
)
return
{
ok
:
true
}
return
{
ok
:
true
}
}
catch
(
err
:
any
)
{
}
catch
(
err
:
any
)
{
return
{
ok
:
false
,
message
:
err
?.
message
??
String
(
err
)
}
return
{
ok
:
false
,
message
:
err
?.
message
??
String
(
err
)
}
}
}
}
)
})
}
it
(
'should not time out when JavaScript chunks load slowly'
,
async
()
=>
{
expect
(
await
loadTrackWithDelayedAssets
(
'**/_next/static/**/*.js*'
)
).
toEqual
({
ok
:
true
})
})
expect
(
result
).
toEqual
({
ok
:
true
})
it
(
'should time out when CSS chunks load slowly'
,
async
()
=>
{
expect
(
await
loadTrackWithDelayedAssets
(
'**/_next/static/**/*.css*'
)
).
toEqual
({
ok
:
false
,
message
:
'Route did not complete loading: /track'
,
})
})
})
})
})
test/e2e/pages-router-route-loader-chunk-delay/pages/track.module.css
0 → 100644
View file @
a4bc6f7a
.track
{
color
:
blue
;
}
test/e2e/pages-router-route-loader-chunk-delay/pages/track.tsx
View file @
a4bc6f7a
import
styles
from
'./track.module.css'
export
default
function
Track
()
{
export
default
function
Track
()
{
return
<
p
id=
"track-content"
>
track page
</
p
>
return
(
<
p
id=
"track-content"
className=
{
styles
.
track
}
>
track page
</
p
>
)
}
}
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