@@ -7,8 +7,9 @@ import { InternalServerError, ValidationError } from "common/errors/index.js";
77const app = await init ( ) ;
88const proxy = awsLambdaFastify ( app , {
99 payloadAsStream : true ,
10- decorateRequest : false , // from original code
11- serializeLambdaArguments : true , // from original code
10+ decorateRequest : false ,
11+ callbackWaitsForEmptyEventLoop : false ,
12+ serializeLambdaArguments : true ,
1213 binaryMimeTypes : [ "application/octet-stream" , "application/vnd.apple.pkpass" ] , // from original code
1314} ) ;
1415
@@ -79,20 +80,12 @@ export const handler = awslambda.streamifyResponse(
7980
8081 // 3. If validation passes, proxy the request and stream the response
8182 try {
82- // The proxy returns a body stream and metadata
83- const { stream : fastifyResponseStream , ...meta } = await proxy (
84- event ,
85- context ,
86- ) ;
87-
88- // Use the helper to apply the status code/headers from Fastify
89- const httpResponseStream = awslambda . HttpResponseStream . from (
83+ const { stream, meta } = await proxy ( event , context ) ;
84+ responseStream = awslambda . HttpResponseStream . from (
9085 responseStream ,
91- meta ,
86+ meta as any ,
9287 ) ;
93-
94- // Pipe the response from Fastify to the Lambda output stream
95- await pipeline ( fastifyResponseStream , httpResponseStream ) ;
88+ await pipeline ( stream , responseStream ) ;
9689 } catch ( e ) {
9790 console . error ( "Error during proxy or stream pipeline:" , e ) ;
9891 const error = new InternalServerError ( {
0 commit comments