File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -105,14 +105,11 @@ export function convertRes(res: OpenNextNodeResponse): InternalResult {
105
105
const isBase64Encoded =
106
106
isBinaryContentType ( headers [ "content-type" ] ) ||
107
107
! ! headers [ "content-encoding" ] ;
108
- // We cannot convert the OpenNextNodeResponse to a ReadableStream directly
109
- // You can look in the `aws-lambda.ts` file for some context
110
- const body = Readable . toWeb ( Readable . from ( res . getBody ( ) ) ) ;
111
108
return {
112
109
type : "core" ,
113
110
statusCode,
114
111
headers,
115
- body,
112
+ body : Readable . from ( res . _chunks ) ,
116
113
isBase64Encoded,
117
114
} ;
118
115
}
Original file line number Diff line number Diff line change @@ -282,6 +282,14 @@ export class OpenNextNodeResponse extends Transform implements ServerResponse {
282
282
return Buffer . concat ( this . _chunks ) ;
283
283
}
284
284
285
+ getBodyLength ( ) : number {
286
+ let size = 0 ;
287
+ for ( const chunk of this . _chunks ) {
288
+ size += chunk . length ;
289
+ }
290
+ return size ;
291
+ }
292
+
285
293
private _internalWrite ( chunk : any , encoding : BufferEncoding ) {
286
294
this . _chunks . push ( Buffer . from ( chunk , encoding ) ) ;
287
295
this . push ( chunk , encoding ) ;
@@ -310,7 +318,7 @@ export class OpenNextNodeResponse extends Transform implements ServerResponse {
310
318
globalThis . __openNextAls
311
319
?. getStore ( )
312
320
?. pendingPromiseRunner . add ( this . onEnd ( this . headers ) ) ;
313
- const bodyLength = this . getBody ( ) . length ;
321
+ const bodyLength = this . getBodyLength ( ) ;
314
322
this . streamCreator ?. onFinish ?.( bodyLength ) ;
315
323
316
324
//This is only here because of aws broken streaming implementation.
@@ -366,8 +374,10 @@ export class OpenNextNodeResponse extends Transform implements ServerResponse {
366
374
}
367
375
368
376
send ( ) {
369
- const body = this . getBody ( ) ;
370
- this . end ( body ) ;
377
+ for ( const chunk of this . _chunks ) {
378
+ this . write ( chunk ) ;
379
+ }
380
+ this . end ( ) ;
371
381
}
372
382
373
383
body ( value : string ) {
You can’t perform that action at this time.
0 commit comments