File tree Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,11 @@ export const runtime = 'edge'
5
5
let streamable
6
6
let requestAborted = false
7
7
8
- export function GET ( req : Request ) : Response {
8
+ export async function GET ( req : Request ) : Promise < Response > {
9
+ // Consume the entire request body.
10
+ // This is so we don't confuse the request close with the connection close.
11
+ await req . text ( )
12
+
9
13
// The 2nd request should render the stats. We don't use a query param
10
14
// because edge rendering will create a different bundle for that.
11
15
if ( streamable ) {
Original file line number Diff line number Diff line change @@ -7,7 +7,11 @@ export const dynamic = 'force-dynamic'
7
7
let streamable
8
8
let requestAborted = false
9
9
10
- export function GET ( req : Request ) : Response {
10
+ export async function GET ( req : Request ) : Promise < Response > {
11
+ // Consume the entire request body.
12
+ // This is so we don't confuse the request close with the connection close.
13
+ await req . text ( )
14
+
11
15
// The 2nd request should render the stats. We don't use a query param
12
16
// because edge rendering will create a different bundle for that.
13
17
if ( streamable ) {
Original file line number Diff line number Diff line change @@ -7,7 +7,11 @@ export const config = {
7
7
let streamable
8
8
let requestAborted = false
9
9
10
- export default function handler ( req : Request ) : Response {
10
+ export default async function handler ( req : Request ) : Promise < Response > {
11
+ // Consume the entire request body.
12
+ // This is so we don't confuse the request close with the connection close.
13
+ await req . text ( )
14
+
11
15
// The 2nd request should render the stats. We don't use a query param
12
16
// because edge rendering will create a different bundle for that.
13
17
if ( streamable ) {
Original file line number Diff line number Diff line change @@ -7,7 +7,11 @@ export const config = {
7
7
let streamable
8
8
let requestAborted = false
9
9
10
- export default function handler ( req : Request ) : Response {
10
+ export default async function handler ( req : Request ) : Promise < Response > {
11
+ // Consume the entire request body.
12
+ // This is so we don't confuse the request close with the connection close.
13
+ await req . text ( )
14
+
11
15
// The 2nd request should render the stats. We don't use a query param
12
16
// because edge rendering will create a different bundle for that.
13
17
if ( streamable ) {
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ export default function handler(
13
13
_req : IncomingMessage ,
14
14
res : ServerResponse
15
15
) : void {
16
+ // Pages API requests have already consumed the body.
17
+ // This is so we don't confuse the request close with the connection close.
18
+
16
19
// The 2nd request should render the stats. We don't use a query param
17
20
// because edge rendering will create a different bundle for that.
18
21
if ( readable ) {
You can’t perform that action at this time.
0 commit comments