File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import awsLambdaFastify from "@fastify/aws-lambda";
22import { pipeline } from "node:stream/promises" ;
33import init , { instanceId } from "./index.js" ;
44import { InternalServerError , ValidationError } from "common/errors/index.js" ;
5+ import { Readable } from "node:stream" ;
56
67// Initialize the proxy with the payloadAsStream option
78const app = await init ( ) ;
@@ -85,7 +86,12 @@ export const handler = awslambda.streamifyResponse(
8586 responseStream ,
8687 meta as any ,
8788 ) ;
88- await pipeline ( stream , responseStream ) ;
89+
90+ // Fix issue with Lambda where streaming repsonses always require a body to be present
91+ const body =
92+ stream . readableLength > 0 ? stream : Readable . from ( Buffer . from ( "" ) ) ;
93+
94+ await pipeline ( body , responseStream ) ;
8995 } catch ( e ) {
9096 console . error ( "Error during proxy or stream pipeline:" , e ) ;
9197 const error = new InternalServerError ( {
You can’t perform that action at this time.
0 commit comments