Open GeoffreyBooth opened 1 year ago
Hey @GeoffreyBooth - thanks for reporting this! Yes, I will take a look at this when I get a chance (might be a couple of weeks).
I've been looking into this a bit since I use this adapter and unfortunately Serverless Express doesn't currently support streaming (see https://github.com/vendia/serverless-express/issues/655). I also see that the response streaming logic present in the official adapter-node has been replaced with response buffering. So it seems to me like the possible solutions to this are either to wait for Serverless Express to start supporting streaming or potentially move the adapter to use a middleware that supports streaming (I think at the moment the only one that does is Middy (see https://middy.js.org/docs/intro/streamify-response)). Both of these solutions would also require the setResponse function to be updated to support streaming again (which should be just a copy and paste from the official adapter-node equivalent)
Yeah, I am watching that serverless-express issue and hoping they can get someone to implement it soon, and I will update this adapter quickly afterward. I unfortunately do not have the time to do the work in serverless-express right now.
I haven't used Middy in production before, so I am hesitant to rewrite this adapter to use it.
Sorry for marketing myself but I had a library serverless-adapter that already supports Streaming Responses.
But be aware the Streaming Responses has some quirks (https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/issues/94).
Currently, I don't support Polka but I can add support for that framework in a few hours (it's very simple).
@H4ad, I'm having a crack at implementing this using your library at https://github.com/bytesnz/sveltekit-adapter-lambda/pull/1 (will put a PR in @tessellator once I've got it working).
So far I've copied the updated handler from adapter-node and copied in the setup of serverless-adapter. I've got it running, but it is currently just returning 0 byte responses. There's probably something simple I need to fix, so will have a look at it tomorrow. Feel free to point out the missing thing if you want to :smile:
Hi, thank you for creating this adapter! AWS lambda supports streamed responses now: https://docs.aws.amazon.com/lambda/latest/dg/configuration-response-streaming.html. This feature allows returning up to 20MB (up from the current limit of 6MB) and should provide a significant performance improvement for page load times as the page headers could be sent immediately while the body is rendered (possibly awaiting calls for data). Would you consider adding support for streaming to this adapter?
See also: