New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streamified response with empty body ignores other response attributes #1189
Comments
Directly to Function URL or through API Gateway?
This is an AWS issue, Middy doesn't override statusCodes within If AWS signals that they won't fix, we could change https://github.com/middyjs/middy/blob/main/packages/core/index.js#L58 to default to PS I recall 3xx statusCodes used to return 500s when it was first released. So, they may be willing to fix. |
@willfarrell Thanks for checking. It’s through a Function URL. I’ll raise a case a AWS and then update this issue with the response. |
While working on the AWS case, I dug into the middy code more closely. I think I found a potential problem in how middy handles strings with no content. Basically, when there's no content in the iterator generator does not yield and then the pipeline then does not process the HttpResponseStream. As far as I can see. To fix this, we can make a simple change. By ensuring the generator always yields content (even if it's just once with no content), we can resolve the issue. use Here's a sample code without middy, but with the algorithm to generate a string response in a stream-like manner.
I had some trouble setting up ava tests on my computer, so I couldn't create a pull request yet. 😞 |
fix: #1189 write prelude in streamifyResponse with string body
Describe the bug
When a Lambda function in invoke mode
RESPONSE_STREAM
andstreamifyResponse=true
returns a response with an empty body (null
or''
), then the other response attributes like statusCode or headers are ignored.To Reproduce
Sample code:
Empty body cause the Lambda to respond with 200 instead if 301
Response headers from client:
e.g. blank body (one space) causes the Lambda to respond correct with 301 and also the headers are present:
Response headers from
Expected behaviour
The other response attributes like statusCode, headers,cookies are return with an empty body.
Environment (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: