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
fb885189
Unverified
Commit
fb885189
authored
Nov 14, 2025
by
Hendrik Liebau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add streaming test case
parent
57ddd363
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
126 additions
and
2 deletions
+126
-2
actions.ts
test/e2e/app-dir/hello-world/app/actions.ts
+24
-0
route.ts
test/e2e/app-dir/hello-world/app/api/stream/route.ts
+25
-0
page.tsx
test/e2e/app-dir/hello-world/app/page.tsx
+54
-1
next.config.js
test/e2e/app-dir/hello-world/next.config.js
+8
-1
page.tsx
test/e2e/app-dir/use-cache/app/(dynamic)/error/page.tsx
+15
-0
No files found.
test/e2e/app-dir/hello-world/app/actions.ts
0 → 100644
View file @
fb885189
'use server'
export
async
function
streamData
(
origin
:
string
)
{
const
response
=
await
fetch
(
new
URL
(
'/api/stream'
,
origin
))
const
[
body1
,
body2
]
=
response
.
body
.
tee
()
const
reader
=
body2
.
getReader
()
;(
async
()
=>
{
try
{
while
(
true
)
{
const
{
done
,
value
}
=
await
reader
.
read
()
if
(
done
)
break
console
.
log
(
'CHUNK'
,
value
.
byteLength
)
}
}
finally
{
reader
.
releaseLock
()
}
})()
return
body1
}
test/e2e/app-dir/hello-world/app/api/stream/route.ts
0 → 100644
View file @
fb885189
import
{
setTimeout
}
from
'timers/promises'
const
loremIpsum
=
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.
\
n'
const
totalBytes
=
5
*
1024
// 32 KB
const
bytesPerChunk
=
100
// bytes per chunk
const
chunkCount
=
Math
.
ceil
(
totalBytes
/
bytesPerChunk
)
export
async
function
GET
()
{
const
encoder
=
new
TextEncoder
()
const
stream
=
new
ReadableStream
({
async
start
(
controller
)
{
for
(
let
i
=
0
;
i
<
chunkCount
;
i
++
)
{
await
setTimeout
(
10
)
controller
.
enqueue
(
encoder
.
encode
(
`
${
i
}
${
loremIpsum
}
`
))
}
controller
.
close
()
},
})
return
new
Response
(
stream
,
{
headers
:
{
'Content-Type'
:
'text/plain'
}
})
}
test/e2e/app-dir/hello-world/app/page.tsx
View file @
fb885189
'use client'
import
{
useState
}
from
'react'
import
{
streamData
}
from
'./actions'
export
default
function
Page
()
{
export
default
function
Page
()
{
return
<
p
>
hello world
</
p
>
const
[
chunks
,
setChunks
]
=
useState
<
string
[]
>
([])
const
[
isStreaming
,
setIsStreaming
]
=
useState
(
false
)
const
handleClick
=
async
()
=>
{
setChunks
([])
setIsStreaming
(
true
)
const
stream
=
await
streamData
(
window
.
location
.
origin
)
// const response = await fetch('/api/stream')
// const stream = await response.body
const
reader
=
stream
.
getReader
()
const
decoder
=
new
TextDecoder
()
try
{
while
(
true
)
{
const
{
done
,
value
}
=
await
reader
.
read
()
if
(
done
)
break
const
chunk
=
decoder
.
decode
(
value
,
{
stream
:
true
})
console
.
log
(
'Received chunk:'
,
chunk
)
setChunks
((
prev
)
=>
[...
prev
,
chunk
])
}
console
.
log
(
'Complete'
)
}
finally
{
reader
.
releaseLock
()
setIsStreaming
(
false
)
}
}
return
(
<
div
>
<
button
disabled=
{
isStreaming
}
onClick=
{
handleClick
}
>
{
isStreaming
?
'Streaming...'
:
'Start Stream'
}
</
button
>
<
div
style=
{
{
marginTop
:
'20px'
,
whiteSpace
:
'pre-wrap'
}
}
>
{
chunks
.
length
>
0
&&
(
<
div
>
<
h3
>
Received
{
chunks
.
length
}
chunks:
</
h3
>
<
div
>
{
chunks
.
map
((
chunk
,
i
)
=>
(
<
div
key=
{
i
}
>
{
chunk
}
</
div
>
))
}
</
div
>
</
div
>
)
}
</
div
>
</
div
>
)
}
}
test/e2e/app-dir/hello-world/next.config.js
View file @
fb885189
/**
/**
* @type {import('next').NextConfig}
* @type {import('next').NextConfig}
*/
*/
const
nextConfig
=
{}
const
nextConfig
=
{
typescript
:
{
ignoreBuildErrors
:
true
,
},
experimental
:
{
taint
:
true
,
},
}
module
.
exports
=
nextConfig
module
.
exports
=
nextConfig
test/e2e/app-dir/use-cache/app/(dynamic)/error/page.tsx
0 → 100644
View file @
fb885189
import
React
from
'react'
let
attempts
=
1
async
function
test
()
{
'use cache'
console
.
log
(
'attempt %d'
,
attempts
++
)
throw
new
Error
(
'bad'
)
}
export
default
async
function
Page
()
{
await
test
()
return
<
p
>
error 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